Problem With Recharging Staves
#1
Posté 30 décembre 2012 - 12:49
Is there a way to prevent the charges from going above 49? Would setting the staves to plot fix this? I did not set the staves to plot, so that I could have them sold at a shop. However I could have the merchant set the staff to plot after purchase, or perhaps an on acquire script.
#2
Posté 30 décembre 2012 - 02:29
#3
Posté 30 décembre 2012 - 05:35
Except plot flag, you can download either my unfficial patch or The Kit's improved magical electrifier or adjust it on your own to check for variable determining maximum charges the item can have.Sadira of Tyr wrote...
I made some magical staves, and I gave them each a unique power, to help make caster classes better. Because the staves are rather pricy, I wanted to be sure they would not disappear when they ran out of charges. I set the charges to 49, and put the unique power at 2 charges per use. The problem is that when the staves are recharged with an item using the magical electrifier spell, the charges go back up to 50. Thus the staff could disappear when reaching zero charges.
Is there a way to prevent the charges from going above 49? Would setting the staves to plot fix this? I did not set the staves to plot, so that I could have them sold at a shop. However I could have the merchant set the staff to plot after purchase, or perhaps an on acquire script.
In CP the variable is called ELECTRIFIER_CHARGE_MAX, type of integer, so simply set it to 49 and the item will be recharged to 49 at max.
#4
Posté 30 décembre 2012 - 10:48
Thank you very much for helping me.
#5
Posté 30 décembre 2012 - 11:30
#6
Posté 30 décembre 2012 - 11:36
So you either dont have community patch 1.71beta or there is a bug in the code that prevent this to work.
as mentioned already, alternatively you can download The Krit's magic electrifier script on vault it has same feature though name of the variable differs.
or I can post you electrifier script from CP1.71b, then you need only to open the original scrip in toolset, paste and compile. Lmk if you want to try this approach.
#7
Posté 30 décembre 2012 - 11:55
Thanks for helping.
#8
Posté 01 janvier 2013 - 01:27
I fixed the problem by changing line 118 to 'else if' instead of just 'if'. Now the script works fine.
#9
Posté 01 janvier 2013 - 01:46
The same problem happens when I save my character. She picked up a staff off the ground, and used a few charges. After using the recharger item, the staff went back up to 49 charges. So far everything is working fine. However when I save the character, and start a new game with the same character, the staff charghes up to 50. The recharger item also loses any charges it has after saving as well.
I'm not sure if the problem is with the electrifier script no longer seeing the variables, or are the items losing the variables. Does the script from the community patch fix these bugs, or is it the same as the Krit's script?
#10
Posté 01 janvier 2013 - 02:12
In case the item in the store is marked as infinity, such item loses any variables when boughtSadira of Tyr wrote...
More strange bugs. I added the variable ELECTRIFIER_CHARGE_MAX to the staves, and set the integer to 49. When my character picks up a staff off the ground, the script works fine, and the charge does not go over 49. However when I buy the same staff from a shop, the charge goes up to 50. Either the staves are losing the variable, or the electrifier script is not reading them correctly.
The same problem happens when I save my character. She picked up a staff off the ground, and used a few charges. After using the recharger item, the staff went back up to 49 charges. So far everything is working fine. However when I save the character, and start a new game with the same character, the staff charghes up to 50. The recharger item also loses any charges it has after saving as well.
I'm not sure if the problem is with the electrifier script no longer seeing the variables, or are the items losing the variables. Does the script from the community patch fix these bugs, or is it the same as the Krit's script?
thats why the The Krit's script doesn't work, neither the one in CP will solve this as it also rely on variables on items
seems the second case is also causing lost of variables, so thats it
it could be possible to fix it using a part of the item tag...
#11
Posté 01 janvier 2013 - 05:59
Sorry, for the trouble guys, and thank you for helping.
#12
Posté 01 janvier 2013 - 06:51
Either directly, or using special script when you first use the staff. Of course if you would like to be able to sell it later than this isn't very good solution.
Other way around this is to give into this staff an unlimited uses spell such as light, problem is this isn't reliable, you might need to swap "position" of this property aka, if adding this property wont prevent item being destroyed, then try remove all cast properties except the unlimited and add them back again, then it should work.
#13
Posté 01 janvier 2013 - 06:59
Pearls wrote...
afaik you can use SetIsDestroyable on it or give it an activation that requires 0 charges
As Pearls said, SetIsDestroyable is a better option if you want to be able to sell the staff.
#14
Posté 01 janvier 2013 - 08:47
Sadira of Tyr wrote...
I made some magical staves, and I gave them each a unique power, to help make caster classes better. Because the staves are rather pricy, I wanted to be sure they would not disappear when they ran out of charges. I set the charges to 49, and put the unique power at 2 charges per use. The problem is that when the staves are recharged with an item using the magical electrifier spell, the charges go back up to 50. Thus the staff could disappear when reaching zero charges.
Is there a way to prevent the charges from going above 49? Would setting the staves to plot fix this? I did not set the staves to plot, so that I could have them sold at a shop. However I could have the merchant set the staff to plot after purchase, or perhaps an on acquire script.
Lets look at this from the other side. Since you gave your Staves a "unique power" I will assume that the Item runs a custom script when used. So would it not be eaiser to just modify that script then modifing the magical electrifier script that effects more items then just the staves?
Just place some code into your "unique power" script that will make sure that the charges are always odd. Something like.
object oStaff = GetItemActivated();
if (~GetItemCharges(oStaff) & 1 ) SetItemCharges(oStaff,GetItemCharges(oStaff)+1);
#15
Posté 01 janvier 2013 - 10:14
Lightfoot8 wrote...
Lets look at this from the other side. Since you gave your Staves a "unique power" I will assume that the Item runs a custom script when used. So would it not be eaiser to just modify that script then modifing the magical electrifier script that effects more items then just the staves?
Just place some code into your "unique power" script that will make sure that the charges are always odd. Something like.
object oStaff = GetItemActivated();
if (~GetItemCharges(oStaff) & 1 ) SetItemCharges(oStaff,GetItemCharges(oStaff)+1);
I tried adding this to my scripts, and it works great. I added the light spell too, just in case, lol.
Thanks guys! You are the greatest!
#16
Posté 06 janvier 2013 - 07:58
I'd presume that the problem with the variable ELECTRIFIER_CHARGE_MAX would be because you only added it to the blueprint and didn't update the item in the shop. Try deleting the item from the shop and then adding it again from the blueprint. If that doesn't work, perhaps using OnAcquireItem to add the variable would work?
Another possible solution: you may be able to fiddle with the OnUnacquireItem script so that it gives the player a no-charges placeholder version of the staff after the last charge is used and the staff is destroyed. You'd also have to change OnAcquireItem to delete the placeholder item and give the player a charged item when they perform the appropriate "charge staff" action.
I hate unsolved problems.
Modifié par Melkior_King, 06 janvier 2013 - 08:03 .
#17
Posté 06 janvier 2013 - 09:14
Melkior_King wrote...
I hate unsolved problems.
Unsolved??
Sadira of Tyr wrote...
I tried adding this to my scripts, and it works great. I added the light spell too, just in case, lol.
Thanks guys! You are the greatest!
#18
Posté 07 janvier 2013 - 03:59
#19
Posté 07 janvier 2013 - 04:48
object oStaff = GetItemActivated();
if (~GetItemCharges(oStaff) & 1 ) SetItemCharges(oStaff,GetItemCharges(oStaff)+1);
AssignCommand(oStaff,SetIsDestroyable(FALSE));
#20
Posté 07 janvier 2013 - 10:40
I prefer the option to add that last line to the script. Much easier, and no need to change the staves at all.
Thank you.
#21
Posté 07 janvier 2013 - 09:56
Lightfoot8 wrote...
ok, Then use:
object oStaff = GetItemActivated();
if (~GetItemCharges(oStaff) & 1 ) SetItemCharges(oStaff,GetItemCharges(oStaff)+1);
AssignCommand(oStaff,SetIsDestroyable(FALSE));
I am still not sure if that solves any issues. If the rod had 3 charges remaining and a 2 charge per use property was used, then the number of charges returned by the if check would be either 3 or 1 depending on when the charges were decremented. Destruction will still occur, though, so ensuring an odd number does not prevent destruction.
EDIT: Doing a quick test I found that SetItemCharges() is too late in preventing destruction if used in the final use spell script.
Modifié par WhiZard, 07 janvier 2013 - 10:09 .
#22
Posté 08 janvier 2013 - 03:40
AssignCommand(oStaff,SetIsDestroyable(FALSE)); Will stop the staff from being destroyed.WhiZard wrote...
Lightfoot8 wrote...
ok, Then use:
object oStaff = GetItemActivated();
if (~GetItemCharges(oStaff) & 1 ) SetItemCharges(oStaff,GetItemCharges(oStaff)+1);
AssignCommand(oStaff,SetIsDestroyable(FALSE));
I am still not sure if that solves any issues. If the rod had 3 charges remaining and a 2 charge per use property was used, then the number of charges returned by the if check would be either 3 or 1 depending on when the charges were decremented. Destruction will still occur, though, so ensuring an odd number does not prevent destruction.
EDIT: Doing a quick test I found that SetItemCharges() is too late in preventing destruction if used in the final use spell script.
if (~GetItemCharges(oStaff) & 1 ) SetItemCharges(oStaff,GetItemCharges(oStaff)+1); will stop the staff from losing all charges and keep him from having to go through the process of delayed iProp removal and re addition to get the staff to have charges again.
It does hinge on the assumption that the staff started with more then three charges though. If the Item started with only 2 or three charges the SetIsDestroyable(FALSE)); would not happen in time to save the staff. If I was 100% on him using TBS I would have added the OnAquite section to the script fragment. But with out him posting his script or *cough* asking for more information, I just posted the fast solution. Since the staff is starting with (assumption) more then three charges.
Modifié par Lightfoot8, 08 janvier 2013 - 03:54 .
#23
Posté 08 janvier 2013 - 04:51
Lightfoot8 wrote...
AssignCommand(oStaff,SetIsDestroyable(FALSE)); Will stop the staff from being destroyed.WhiZard wrote...
Lightfoot8 wrote...
ok, Then use:
object oStaff = GetItemActivated();
if (~GetItemCharges(oStaff) & 1 ) SetItemCharges(oStaff,GetItemCharges(oStaff)+1);
AssignCommand(oStaff,SetIsDestroyable(FALSE));
I am still not sure if that solves any issues. If the rod had 3 charges remaining and a 2 charge per use property was used, then the number of charges returned by the if check would be either 3 or 1 depending on when the charges were decremented. Destruction will still occur, though, so ensuring an odd number does not prevent destruction.
EDIT: Doing a quick test I found that SetItemCharges() is too late in preventing destruction if used in the final use spell script.
if (~GetItemCharges(oStaff) & 1 ) SetItemCharges(oStaff,GetItemCharges(oStaff)+1); will stop the staff from losing all charges and keep him from having to go through the process of delayed iProp removal and re addition to get the staff to have charges again.
It does hinge on the assumption that the staff started with more then three charges though. If the Item started with only 2 or three charges the SetIsDestroyable(FALSE)); would not happen in time to save the staff. If I was 100% on him using TBS I would have added the OnAquite section to the script fragment. But with out him posting his script or *cough* asking for more information, I just posted the fast solution. Since the staff is starting with (assumption) more then three charges.
I am really hesistant at recommending the SetIsDestroyable() flag to be used. It will solve the destruction even when the charges are low, because it blocks the actual destruction. But it also blocks DestroyObject() which can cause a whole host of problems as the game is not set up to check this flag when it performs many of its copying functions. For instance, a staff that is not destroyable will be replicated many times in one's inventory when using craft weapon to modify the appearance.
As for ensuring the charges are always at least 1, you could change your if statement to only check for when the charges reach zero as they are depleted before the script fires.
#24
Posté 08 janvier 2013 - 05:25
WhiZard wrote...
I am really hesistant at recommending the SetIsDestroyable() flag to be used.... But it also blocks DestroyObject() ...
Hmm, Now that could cause problems.
\\As for ensuring the charges are always at least 1, you could change your if statement to only check for when the charges reach zero as they are depleted before the script fires.
no, That brings up another host of problems. When an item drops to 0 charges, it can no longer be charged, leading to another batch of workarounds.
#25
Posté 08 janvier 2013 - 05:28
void main()
{
object oStaff = GetItemActivated();
int nCharges = GetItemCharges(oStaff);
int nChargePerUse = 2;
if (nCharges < nChargePerUse)
{
AssignCommand(oStaff,SetIsDestroyable(FALSE));
DelayCommand(0.5, AssignCommand(oStaff, SetIsDestroyable(TRUE)));
if(!nCharges) SetItemCharges(oStaff, 1);
}
EDIT added the ! so the check would be for zero charges
Modifié par WhiZard, 08 janvier 2013 - 05:36 .





Retour en haut







