Author Topic: ActionTakeItem and exceptions  (Read 546 times)

Legacy_Icezera

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
ActionTakeItem and exceptions
« on: October 14, 2015, 10:13:37 am »


               

Hey all, kinda new to nwn scripting so please be patient. There is a module I am playing (gladiatrix) which I have installed PRC. I am playing as a swordsage. If you know a little about PRC, you will know that the swordsage's manuevers are granted through bonus feats. These bonus feats are stored in a hidden item called base_prc_skin. This is all well and good until events happen in the module where my pc is taken prisoner and loses all items through the actiontakeitem script which ends up taking the base_prc_skin, crippling my swordsage of all her manuevers.


 


So, is there any way to make exceptions to the script so it doesn't take the base_prc_skin?


 


If someone can tell me how to do it properly, I think I can copy and paste the relevant script code here too.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #1 on: October 14, 2015, 02:01:32 pm »


               

If you can post the script that would help.  Is base_prc_skin the tag of the item? Knowing the tag will help. But how to make the code skip it depends on how the code currently is written.



               
               

               
            

Legacy_Icezera

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #2 on: October 14, 2015, 06:01:11 pm »


               
void CreateItemOnObjectVoid(string sItemTemplate, object oTarget=OBJECT_SELF, int nStackSize=1)

{

CreateItemOnObject(sItemTemplate, oTarget, nStackSize);

}

/*   Script generated by

Lilac Soul's NWN Script Generator, v. 2.3

 

For download info, please visit:

http://nwvault.ign.c...&id=4683&id=625   */

 

//Put this on action taken in the conversation editor

#include "nw_i0_generic"

void main()

{

 

object oPC = GetPCSpeaker();

 

 

 

 

 

FadeToBlack(oPC, FADE_SPEED_MEDIUM);

 

 

 

 

 

 

 

object oTessa;

oTessa = GetObjectByTag("Tessa9");

 

 

object oKristaly;

oKristaly = GetObjectByTag("Kristaly3");

 

 

object oLandon;

oLandon = GetObjectByTag("Landon3");

 

 

RemoveHenchman(oPC, oTessa);

 

RemoveHenchman(oPC, oKristaly);

 

RemoveHenchman(oPC, oLandon);

 

 

 

 

 

object oTarget;

 

oTarget = GetObjectByTag("ScourgeChest");

 

object oItem;

oItem = GetFirstItemInInventory(oPC);

 

while (GetIsObjectValid(oItem))

   {

   DelayCommand(1.5,AssignCommand(oTarget, ActionTakeItem(oItem, oPC)));

 

   oItem = GetNextItemInInventory(oPC);

   }

 

int nInt;

for (nInt=0; nInt<NUM_INVENTORY_SLOTS; nInt++)

   {

   oItem = GetItemInSlot(nInt, oPC);

 

   if (GetIsObjectValid(oItem))

         DelayCommand(1.5,AssignCommand(oTarget, ActionTakeItem(oItem, oPC)));

   }

 

DelayCommand(1.5,AssignCommand(oTarget, TakeGoldFromCreature(GetGold(oPC), oPC)));

 

 

 

DelayCommand(1.7,AssignCommand(oPC, ClearAllActions()));

 

DelayCommand(1.8, CreateItemOnObjectVoid("slavecostume", oPC));

 

 

 

DelayCommand(2.2, AssignCommand(oPC, ActionEquipItem(GetItemPossessedBy(OBJECT_SELF, "SlaveCostume"), INVENTORY_SLOT_CHEST)));

 

 

 

 

DelayCommand(2.7,AssignCommand(oPC, ActionJumpToObject(GetObjectByTag("WP_PCScourgeCell"))));

 

 

DelayCommand(3.0,FadeFromBlack(oPC, FADE_SPEED_SLOW));

 

}

 

 

This is the code. Sorry if this isn't in the right format. Not sure how to make it easy to read or make it smaller


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #3 on: October 14, 2015, 06:33:26 pm »


               

Since I don't know for sure if this is equipped there are two places you need to add code.


 


First in the while loop make it look like this:



while (GetIsObjectValid(oItem))
   {
   if (GetTag(oItem) == "base_prc_skin") {
         oItem = GetNextItemInInventory(oPC);
         continue;
   }

   DelayCommand(1.5,AssignCommand(oTarget, ActionTakeItem(oItem, oPC)));

i.e. add the 4 lines in the middle, leave the rest as is. This assumes the tag of the item is base_prc_skin.


 


And then in the for loop make it look like this:



for (nInt=0; nInt<NUM_INVENTORY_SLOTS; nInt++)
   {
   if (nInt == INVENTORY_SLOT_CARMOUR) continue;
   oItem = GetItemInSlot(nInt, oPC);

i.e. add that "if (nInt..." line and leave the rest as is.


 


Or you could change NUM_INVENTORY_SLOTS to INVENTORY_SLOT_CWEAPON_L  to skip all the creature slots on the PC.


               
               

               
            

Legacy_Icezera

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #4 on: October 14, 2015, 10:24:27 pm »


               

Thank you! I will try this and hopefully it works. I will have to start a new game unfortunately so it may take time...



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #5 on: October 14, 2015, 10:54:25 pm »


               

Good luck!  Make sure you do a full build (with compile scripts checked) of the module if this is in an include file.



               
               

               
            

Legacy_Icezera

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #6 on: October 15, 2015, 10:20:38 am »


               

Umm, I'm trying to compile the code but it keeps including x0_i0_talent which seems to have an error starting at line 1150. Not sure what to do. Here is the relevant part of the code.


 



//MyPrintString("Talent Spell Attack Failed Exit");
    /* JULY 2003
       At this point grab a random spell attack to use, not just "best"
    */
    //SpawnScriptDebugger();
     tUse = GetCreatureTalentRandom(TALENT_CATEGORY_HARMFUL_AREAEFFECT_DISCRIMINANT);
     if (GetIsTalentValid(tUse) == FALSE || bkTalentFilter(tUse, oTarget, TRUE)==FALSE)
     {
      tUse = GetCreatureTalentRandom(TALENT_CATEGORY_HARMFUL_RANGED);
     }
     if (GetIsTalentValid(tUse) == FALSE || bkTalentFilter(tUse, oTarget, TRUE)==FALSE)
     {
      tUse = GetCreatureTalentRandom(TALENT_CATEGORY_HARMFUL_AREAEFFECT_INDISCRIMINANT);
     }
     if (GetIsTalentValid(tUse) == FALSE || bkTalentFilter(tUse, oTarget, TRUE)==FALSE)
     {
      tUse = GetCreatureTalentRandom(TALENT_CATEGORY_HARMFUL_TOUCH);
     }

               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #7 on: October 15, 2015, 02:53:01 pm »


               

What is the error being reported?



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #8 on: October 15, 2015, 03:37:36 pm »


               

Also, looking at the whole script more closely... it's not an include so you could just save that (assuming you have compile on save checked) and not do a whole module build.



               
               

               
            

Legacy_Icezera

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #9 on: October 15, 2015, 05:01:12 pm »


               

The error being reported is that the declaration does not match the parameters. Which is strange since I thought x0_i0_talent was a default file which means it shouldn't have issues right?


 


Also, is there any way to insert changed scripts into a saved game? I have a save now right before the issue happens and when I tested it, the issue still happened. But I am not sure that the fixed script compiled since I merely saved it after editing and when it tried to compile, it reported that it didn't compile but since it saved I had assumed it was ok.


 


So if I want to test changes, I need to be able to insert scripts into my saved game since according to my understanding each saved game uses a separate copy of the module so making changes to the base module would not actually help.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #10 on: October 15, 2015, 06:39:57 pm »


               

It is yes. I don't know how PRC gets added to existing modules. Presumably through override/. There may be a version of that script in there?  I don't know why that would be effected.  Every now and then when I compile something in the toolset it throws an error in some unmodified code. Compiling it again usually clears that up. I'm not sure if that's an artifact of using Wine or not.


 


In the past I've copied the saved module to have a .mod extension and then used the toolset. And then re-copied it. At least I think that's what I did. I may have used non-bioware command line tools to open it...


 


If you can get it to compile you can copy the .ncs file for it out of the modules/temp0 directory and into override. Then load your unmodified save game. I think that will work, but I've not tried it.


 


If  you post the script as it currently stands maybe some nice soul will compile it for you.



               
               

               
            

Legacy_Icezera

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
ActionTakeItem and exceptions
« Reply #11 on: October 15, 2015, 06:53:45 pm »


               

Got it! I made a new module, copied the nss file into it, compiled it successfully there and inserted it into my save file which worked. Thanks for your help!