Author Topic: Problem With Recharging Staves  (Read 1197 times)

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« on: December 30, 2012, 12:49:02 am »


               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.
               
               

               
            

Legacy_Pearls

  • Full Member
  • ***
  • Posts: 194
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #1 on: December 30, 2012, 02:29:56 am »


               afaik you can use SetIsDestroyable on it or give it an activation that requires 0 charges
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #2 on: December 30, 2012, 05:35:54 am »


               

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.

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.

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.
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #3 on: December 30, 2012, 10:48:55 am »


               I will try the variable. That is easy enough for me to do. I can also give the staves a light spell for zero charges.

Thank you very much for helping me.  'Posted
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #4 on: December 30, 2012, 11:30:17 am »


               Well, I tried the variable on the staff, but the charges still went up to 50. I then tried it on the electrifier item with the same result.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #5 on: December 30, 2012, 11:36:27 am »


               This variable will work only with community patch and will modify the electrifier so recharging will be limited to value in this variable. Also forget to mention that this feature was added in one of the beta versions, its not in 1.70 initial release...
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.
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #6 on: December 30, 2012, 11:55:29 pm »


               Yeah, I misunderstood your post. Now that I read it again, it is more clear to me. I am not the server host, so adding the patch is not really an option for me. I have downloaded the Krits electrifier from the Vault, and I will try that. It has some features that make it much better.

Thanks for helping.  'Posted
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #7 on: January 01, 2013, 01:27:57 am »


               Well, I found a bug in the Krit's magical electrifier script. According to the script, the electrifier should not destroy plot or cursed items. However when I tested the script, my recharger item would post a message "failure invalid target", and then it would destroy the item anyways.

I fixed the problem by changing line 118 to 'else if' instead of just 'if'. Now the script works fine.
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #8 on: January 01, 2013, 01:46:37 pm »


               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?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #9 on: January 01, 2013, 02:12:21 pm »


               

Sadira 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?

In case the item in the store is marked as infinity, such item loses any variables when bought

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...
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #10 on: January 01, 2013, 05:59:41 pm »


               Oh well, I guess I will just set the staves to 50 charges, and have the unique power take 3 charges per use. It will mean 8 less charges, but there will not be a risk of losing the staff. I will still use the Krit's script though, since I like the features it has. 

Sorry, for the trouble guys, and thank you for helping. 'Posted
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #11 on: January 01, 2013, 06:51:42 pm »


               I don't exactly know what you need, but if the main intent is not to lose the staff, then you can set the staff to be plot.

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.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #12 on: January 01, 2013, 06:59:38 pm »


               

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.  
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #13 on: January 01, 2013, 08:47:40 pm »


               

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);  
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #14 on: January 01, 2013, 10:14:10 pm »


               

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! 'Posted