Author Topic: Vanishing NPC and Henchman Level Up  (Read 510 times)

Legacy_Werthers Chewbackas

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« on: November 10, 2010, 11:46:18 pm »


               Trying to add a few lines that will make my NPC henchman vanish after a conversation. As well, I'm trying to add a conversation that will level him up to 1 level beneath the PC. I've been using Lilac's program for the latter and, for the vanishing NPC script, I pulled it off a Google search and it works for other NPCs but only if they aren't attached as a henchmen or, perhaps, don't have a henchman script set?

The two scripts in question (After-conversation action called from the conversation):

#include "nw_i0_tool"
void main()
{

object oPC = GetPCSpeaker();

AddJournalQuestEntry("GrimCompanions", 2, oPC, TRUE, FALSE, TRUE);

RewardPartyXP(1000, oPC, FALSE);

object oTarget;
oTarget=GetHenchman(oPC);

RemoveHenchman(oPC, oTarget);

}

The above is working properly. This part, however, is not:

ActionForceMoveToObject (GetObjectByTag ("APsychoticDruid"), TRUE, 0.2, 10.);
ActionDoCommand( DestroyObject( OBJECT_SELF ) );
SetCommandable( FALSE );

}

I have been testing this with the NPC in question alongside me as a copy, with the original located somewhere else in the module when this script line is called for...Don't think that's relevant though considering the other 3 actions are working properly.

The Level-Up Script (Also called from a conversation):

void main()
{

object oPC = GetPCSpeaker();

object oTarget;
oTarget = GetHenchman(oPC);

int nInt;
if (GetIsObjectValid(oTarget))
   {
   nInt = GetHitDice(oPC) - GetHitDice(oTarget);

   while (nInt>0)
      {
      LevelUpHenchman(oTarget);
      nInt--;
      }
   }
}

Again, help is really appreciated. This is the first real module I'm creating so I'm a bit of a newbie at this stuff. I don't know anything about integer variables and the Lexicon as well as a Toolset Manual PDF haven't yielded anything useful.
               
               

               


                     Modifié par Werthers Chewbackas, 10 novembre 2010 - 11:47 .
                     
                  


            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #1 on: November 11, 2010, 12:00:12 am »


               Try setting a local int in the conversation then checking for that local in the in conversation abort/end scripts (Under the "Current File" tab in the conversation editor. Then have the NPC execute those commands after the dialogue window shuts down.



-420
               
               

               
            

Legacy_Werthers Chewbackas

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #2 on: November 11, 2010, 04:06:40 am »


               Sorry for my lack of comprehension but I don't know how to do that and I haven't been able to figure it out either.

I am trying to use the x1_playerlevelup script in the OnPlayerLevelUp event in the Module Properties but I receive the error message:

"Level up failed for a psychotic druid in class 3."

I'm really at a loss for why Lilac's script or the other wouldn't work.
               
               

               


                     Modifié par Werthers Chewbackas, 11 novembre 2010 - 04:13 .
                     
                  


            

Legacy_Werthers Chewbackas

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #3 on: November 11, 2010, 08:58:59 pm »


               Anyone? These are the last two scripts I need to finish my module up. Maybe someone could tell me how to set a local int in the conversation?
               
               

               
            

Legacy_Werthers Chewbackas

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #4 on: November 12, 2010, 02:33:42 am »


               Setting a local integer and checking for it using an if conditional, then setting the "Normal" and "Aborted" files to the script associated with the following did not help.

Don't know what else to do from here '<img'>

The script I'm using:
void main()
{

object oPC = GetPCSpeaker();

SetLocalInt(oPC, "LevelUp", 1);

object oTarget;
oTarget = GetHenchman(oPC);

int nInt;
if (GetIsObjectValid(oTarget))
  {
  nInt = GetHitDice(oPC) - GetHitDice(oTarget);

  while (nInt>0)
     {
     LevelUpHenchman(oTarget);
     nInt--;
     }
  }
}
               
               

               


                     Modifié par Werthers Chewbackas, 12 novembre 2010 - 02:36 .
                     
                  


            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #5 on: November 12, 2010, 03:05:33 pm »


               You might try doing the end of the script like this:

int nclass = GetclassByPosition(1, oTarget);
int nPackage = GetCreatureStartingPackage(oTarget);

while (GetHitDice(oPC) > GetHitDice(oTarget))
{
LevelUpHenchman(oTarget, nclass, TRUE, nPackage);
}

EDIT: For whatever reason the "C" in all the words "class" above keep being set as lower case, no matter how many times I edit it to make it capital C like it should be.... damned forums....

You mentioned that you are testing on a copy of the Hench while the "real one" is in another area, so might want to stick a check in there to see if you are getting the right one:

if (GetArea(oPC) != GetArea(oTarget))
{
FloatingTextStringOnCreature("Henchman is not in the same area as PC!", oPC); // Debug
}

Also, you may find my tutorial helpful, written for beginning scripters. While done with NWN2 in mind the vast majority of it applies to NWN1 as well. Link in sig below.
               
               

               


                     Modifié par _Knightmare_, 12 novembre 2010 - 03:10 .
                     
                  


            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #6 on: November 12, 2010, 10:31:03 pm »


               I put a brief post into the SCRIPTING SOLUTIONS thread on keeping a henchman leveled up.  One thing to note is that LevelUpHenchman only works right on a henchman that is leveled up ONLY using the LevelUpHenchman function. If you design a level 3 henchman and then try to level it up in the module using LevelUpHenchman it will NOT work.  The henchman has to be level 1 when it gets spawned.  It then can only be leveled up using the LevelUpHenchman script.
               
               

               


                     Modifié par Mudeye, 12 novembre 2010 - 10:34 .
                     
                  


            

Legacy_Werthers Chewbackas

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #7 on: November 13, 2010, 05:16:23 am »


               Thanks for the effort but I haven't had any success with those three. I am using this on only one existing copy of the NPC in the module, I deleted and re-made him using the same tag and starting at level one. I'll will try the PDF!
               
               

               
            

Legacy_Werthers Chewbackas

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #8 on: November 15, 2010, 03:56:40 am »


               Not really sure where to go from here. Just about every script I try to build myself doesn't work. I can only seem to get the most basic scripts from Lilac to work, for the most part. A local integer script as simple as

void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
SetLocalInt(oPC, "Testing1", 3);
}

void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) && if (GetLocalInt(oPC, "Testing1")== 3) return;
   {
   FloatingTextStringOnCreature("???", oPC);
   }
}

doesn't work. Scripts that utilize items and spawnable/placeable NPCs use their tags and not their res reference in opposition to what every scripting tutorial/guide I have read so far says. This is probably where my scripting endeavours end, although I'm thankful I'm able to successfully make the "NPC joins as henchman" and other rudimentary things.

[Edited for script spacing]
               
               

               


                     Modifié par Werthers Chewbackas, 15 novembre 2010 - 04:02 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #9 on: November 15, 2010, 04:17:45 am »


               um The second script does not even compile.


void main()
{
    object oPC = GetEnteringObject();
    if (!GetIsPC(oPC) || (GetLocalInt(oPC, "Testing1")!= 3)) return;

    FloatingTextStringOnCreature("???", oPC);

}

Would come closer to what I think your are trying to do with the test. 
               
               

               


                     Modifié par Lightfoot8, 15 novembre 2010 - 04:19 .
                     
                  


            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #10 on: November 15, 2010, 12:55:28 pm »


               

Werthers Chewbackas wrote...

Scripts that utilize items and spawnable/placeable NPCs use their tags and not their res reference in opposition to what every scripting tutorial/guide I have read so far says. This is probably where my scripting endeavours end, although I'm thankful I'm able to successfully make the "NPC joins as henchman" and other rudimentary things.


While it may not be true 100% of the time, it is true enough to consider the following a "rule of thumb" in scripting:

- When something does not yet exist in game (for example you are calling on the blueprint of an NPC to spawn) you reference the blueprint's ResRef. Once it does exist in game (example you are calling on the NPC you just spawned) then you reference the object's tag.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #11 on: November 17, 2010, 01:09:11 am »


               

  Scripts that utilize items and spawnable/placeable NPCs use their tags and not their res reference in opposition to what every scripting tutorial/guide I have read so far says. This is probably where my scripting endeavours end, although I'm thankful I'm able to successfully make the "NPC joins as henchman" and other rudimentary things.

 

Could post the tutorials So we could take a look at them.  If nothing else just so we know the ones in error. That way we will not direct others to them.  Or get the author to correct them if they are still around.


 
               
               

               
            

Legacy__Knightmare_

  • Full Member
  • ***
  • Posts: 191
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #12 on: November 17, 2010, 01:32:15 pm »


               If the mentioned error lies somewhere in my tutorial (linked below in sig) please point out where that is. I try to keep it accurate and update it every so often.
               
               

               
            

Legacy_Werthers Chewbackas

  • Jr. Member
  • **
  • Posts: 54
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #13 on: November 17, 2010, 06:40:27 pm »


               Pretty much everywhere it says resref like:

5. (entered a resref of a creature “c_reddragon” no quotes), No visual effect, (entered At the Waypoint:
“spawn_here” no quotes), Talk to PC

Even the official toolset tutorial I got from Bioware (I think it's their official one) does this. It might very well be something with my computer, not sure. I'd also like to point out that I was able to get the henchman to level up with a conversation when I loaded his script set with the XP2 henchman set. Still haven't figured out the "DestroySelf" command after the "ReleaseHenchman" command. I'll try setting a local int on the PC, set an If conditional after the "RH" script line and see if that works.

The working level up script (when loading XP2 script set):

void main()
{
object oPC = GetPCSpeaker();
object oTarget;
oTarget = GetHenchman(oPC);
int nInt;
if (GetIsObjectValid(oTarget))
  {
  nInt = GetHitDice(oPC) - GetHitDice(oTarget);
while (nInt>0)
     {
     LevelUpHenchman(oTarget);
     nInt--;
     }
  }
}

[Edit]
Sometimes a script won't work (even if perfectly written) and a computer restart gets it to and sometimes if I write one up and then re-write it, the previously written script is what runs instead of the new one. Should I just make a new one and re-name it every time?
               
               

               


                     Modifié par Werthers Chewbackas, 17 novembre 2010 - 06:58 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Vanishing NPC and Henchman Level Up
« Reply #14 on: November 17, 2010, 06:59:02 pm »


               Question:  Are you compiling your scripts, saving the game and restarting the module befor trying to see if your changes took effect?



I would also still like to see a link to a tutorial that you are saying is in Error.  Every function that creates an Object from a blueprint will have to use the ResRef to create the object.  Most functions that find instances of objects use the Tag of the Object.