Aller au contenu

Photo

Adding Spell Slots By Script


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
Sadira of Tyr

Sadira of Tyr
  • Members
  • 172 messages
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);
      }
}

#2
Shadooow

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

#3
Sadira of Tyr

Sadira of Tyr
  • Members
  • 172 messages
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.

#4
Sadira of Tyr

Sadira of Tyr
  • Members
  • 172 messages
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 Image

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


#5
Shadooow

Shadooow
  • Members
  • 4 474 messages
yup, variable on amulet is probably best approach for this

#6
Sadira of Tyr

Sadira of Tyr
  • Members
  • 172 messages
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 .


#7
Shadooow

Shadooow
  • Members
  • 4 474 messages
try this then

AddItemProperty(DURATION_TYPE_PERMANENT,ipAdd,oItem);

#8
Sadira of Tyr

Sadira of Tyr
  • Members
  • 172 messages
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 Image