Author Topic: How to stop item vanishing with last charge?  (Read 566 times)

Legacy_Tyndrel

  • Sr. Member
  • ****
  • Posts: 313
  • Karma: +0/-0
How to stop item vanishing with last charge?
« on: December 06, 2010, 09:00:16 pm »


               I have an artifact with 5 charges, cast spell: unique power, and a tag based script.  The artifact is intended to be returned to an alter and recharged when it's charges are used up but it vanishes with the last charge. I've made it plot, to no effect and dispite having charges set to 5, I tried giving it unlimited uses on the properties page but it still disappears. 

Any suggestions?  ':wizard:'
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How to stop item vanishing with last charge?
« Reply #1 on: December 06, 2010, 09:49:28 pm »


               There are two ways to go about it. 
One
Make it to where the Item cam not be destroyed using the SetIsDestroyable function

// Set the destroyable status of the caller.
// - bDestroyable: If this is FALSE, the caller does not fade out on death, but
//   sticks around as a corpse.
// - bRaiseable: If this is TRUE, the caller can be raised via resurrection.
// - bSelectableWhenDead: If this is TRUE, the caller is selectable after death.
void SetIsDestroyable(int bDestroyable, int bRaiseable=TRUE, int bSelectableWhenDead=FALSE)



Two]

Give the Item an Odd number of charges that will never be able to reduce the iten to 0 charges.

Ex.
Have the item use 2 charges per use and have 11 charges. 
that way after the item is used 5 times it still have one charge but can not be used again.  

EDIT:  Option 2 is better then option 1.  Even if the item is not destroyed after using SetIsDestroyable(FALSE); on it.  You will find that other things will arise that will have to be dealt with after the item drops to 0 charges.
               
               

               


                     Modifié par Lightfoot8, 06 décembre 2010 - 09:54 .
                     
                  


            

Legacy_Tyndrel

  • Sr. Member
  • ****
  • Posts: 313
  • Karma: +0/-0
How to stop item vanishing with last charge?
« Reply #2 on: December 07, 2010, 01:18:51 am »


               Brilliant, my brain was stuck in neutral, thanks, 11 charges it is '<img'>
               
               

               
            

Legacy_CheeseshireCat

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-0
How to stop item vanishing with last charge?
« Reply #3 on: December 07, 2010, 01:42:40 pm »


               Three. Since it is a unique power anyway... Don't use "standard" charges, instead using a decrementing variable in the script handling it. Maybe even change the item name to reflect the number of charges left if you feel like that.
               
               

               
            

Legacy_Tyndrel

  • Sr. Member
  • ****
  • Posts: 313
  • Karma: +0/-0
How to stop item vanishing with last charge?
« Reply #4 on: December 07, 2010, 02:47:36 pm »


               Thanks CheeseshireCat, another fine solution, I will however be going with the non-scripted idea, I'm not the best scripter in the world, in fact I'm not the best scripter in my house, I seem to recall a slightly overweight spider running across my keyboard on one occasion, but at least his efforts compiled!
               
               

               
            

Legacy_CheeseshireCat

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-0
How to stop item vanishing with last charge?
« Reply #5 on: December 07, 2010, 03:31:19 pm »


               Just out of curiosity -- what is the "unique power" you have it have that it is non-scripted? o.O

... And I have a weirder story as to what was typing on my keyboard...
               
               

               
            

Legacy_Tyndrel

  • Sr. Member
  • ****
  • Posts: 313
  • Karma: +0/-0
How to stop item vanishing with last charge?
« Reply #6 on: December 07, 2010, 05:08:00 pm »


               No, it is scripted, I do bits with Lilac Soul and cutting and pasting and loads of help from the Lexicon (not to mention scratching my head until I get splinters!) but for more complex things I turn to my good buddy Baragg who seems to be able to make anything do anything and I only owe him my right arm, both legs and my firstborn, quite reasonable really.  '<img'>
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
How to stop item vanishing with last charge?
« Reply #7 on: December 08, 2010, 01:50:16 pm »


               

Lightfoot8 wrote...

There are two ways to go about it. 
One
Make it to where the Item cam not be destroyed using the SetIsDestroyable function

// Set the destroyable status of the caller.
// - bDestroyable: If this is FALSE, the caller does not fade out on death, but
//   sticks around as a corpse.
// - bRaiseable: If this is TRUE, the caller can be raised via resurrection.
// - bSelectableWhenDead: If this is TRUE, the caller is selectable after death.
void SetIsDestroyable(int bDestroyable, int bRaiseable=TRUE, int bSelectableWhenDead=FALSE)



Two]

Give the Item an Odd number of charges that will never be able to reduce the iten to 0 charges.

Ex.
Have the item use 2 charges per use and have 11 charges. 
that way after the item is used 5 times it still have one charge but can not be used again.  

EDIT:  Option 2 is better then option 1.  Even if the item is not destroyed after using SetIsDestroyable(FALSE); on it.  You will find that other things will arise that will have to be dealt with after the item drops to 0 charges.


Due to my inquisitive nature, could you illuminate the possibly bad side effects of setting the destroyable int?

Edit: I don't really do much. I just ask a bunch of questions and the community usually supplies the answers, but thanks Tyn you rock man.
               
               

               


                     Modifié par Baragg, 08 décembre 2010 - 01:51 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How to stop item vanishing with last charge?
« Reply #8 on: December 08, 2010, 09:32:01 pm »


               The answer was short because I only half remember Myself. Lets see how well I remember this.

Once an item uses its last charge it it gets marked as not having charges. When you try to add charges back to the item using SetItemCharges It simply does nothing. In order to fix this and allow the item to charge again you have to add a new item property to the Item and remove the old one. It can get a little tricky because some of the functions run while the script is running (Like SetCharges) while other run after the script finishes(RemoveItemProptery). So just about every function needs to be delayed untill after the script inorder to happen in the right order.
 
Edit: lol , Well I think you answered the question form the OP here.  I think it was from one of your posts that I originaly read the idea to give the item an odd number of charges.

EDIT2:  OOps it was WhiZard's post. 
http://nwn.bioware.c...721678&forum=46
               
               

               


                     Modifié par Lightfoot8, 08 décembre 2010 - 10:20 .