Author Topic: Adding Spell Slots By Script  (Read 410 times)

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Adding Spell Slots By Script
« on: February 26, 2013, 11:32:14 pm »


               I'm trying to make a quest reward script, that adds spell slots to a character's amulet. The script takes the quest item, and gives xp and gold, but it does not add the spell slots. The script compiled fine, so I'm not sure why it did not add the spell slots. Is there something I do not know about? Any help would be greatly appreciated.

Here is the script:

#include "x2_inc_itemprop"

void main()
{
    // Get the PC who is in this conversation.
    object oPC = GetPCSpeaker();
    object oParty = GetFirstFactionMember(oPC);
    object oItem;
    itemproperty ipAdd;

   // Alter the necklace equipped by the PC.
    oItem = GetItemInSlot(INVENTORY_SLOT_NECK, oPC);
    ipAdd = ItemPropertyBonusLevelSpell(IP_CONST_class_WIZARD, IP_CONST_SPELLLEVEL_6);
    IPSafeAddItemProperty(oItem, ipAdd);
    IPSafeAddItemProperty(oItem, ipAdd);
    IPSafeAddItemProperty(oItem, ipAdd);
    IPSafeAddItemProperty(oItem, ipAdd);
    IPSafeAddItemProperty(oItem, ipAdd);

   oItem = GetFirstItemInInventory(oPC);
    while (GetIsObjectValid(oItem))
      {
         if (GetTag(oItem)=="IlaniasBlackHeart")
         {
          DestroyObject(oItem);
         }
         oItem = GetNextItemInInventory(oPC);
      }
      while(GetIsObjectValid(oParty))
      {
         if(GetArea(oPC)==GetArea(oParty))
         {
            GiveGoldToCreature(oParty, 50000);
            GiveXPToCreature(oParty, 5000);
            }
      oParty = GetNextFactionMember(oPC);
      }
}
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Adding Spell Slots By Script
« Reply #1 on: February 26, 2013, 11:36:20 pm »


               remove "IPSafe" and it should work, the IPSafeAddItemProperty is a custom function that has built-in check for existence of the same property
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Adding Spell Slots By Script
« Reply #2 on: February 26, 2013, 11:45:25 pm »


               Thank you for that.

I have a question though. I would like the script to only give the spell slots if the amulet has not gotten the spell slots before. I'm sure that sounds confusing, lol. What I mean is that I would like the amulet to have only five spell slots, even if the character completes the quest again. Allowing the slots to go to 10, then 15, etc, would be unbalancing.
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Adding Spell Slots By Script
« Reply #3 on: February 26, 2013, 11:58:55 pm »


               I guess I could solve that on my own by adding a variable to the amulet as well. Silly me, lol.

Thank you ShaDoOoW. 'Posted
               
               

               


                     Modifié par Sadira of Tyr, 26 février 2013 - 11:59 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Adding Spell Slots By Script
« Reply #4 on: February 27, 2013, 12:26:48 am »


               yup, variable on amulet is probably best approach for this
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Adding Spell Slots By Script
« Reply #5 on: February 27, 2013, 12:45:23 am »


               Oops! I guess I should have tried the fix first.

I removed the IPSafe, but the script would not compile, declaration does not match parameters, on the line with AddItemProperty. I guess I need to make another change, but I'm not sure what that would be. I guess I could use some more help, lol.
               
               

               


                     Modifié par Sadira of Tyr, 27 février 2013 - 12:47 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Adding Spell Slots By Script
« Reply #6 on: February 27, 2013, 12:54:55 am »


               try this then

AddItemProperty(DURATION_TYPE_PERMANENT,ipAdd,oItem);
               
               

               
            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Adding Spell Slots By Script
« Reply #7 on: February 27, 2013, 01:21:10 am »


               Ah, now it compiles fine. I have tested it, and the spell slots were added. I just need to add the variable, but I can manage that on my own. Well, I hope so, lol.

Thank you for helping me. 'Posted