Aller au contenu

Photo

Vanishing NPC and Henchman Level Up


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

#1
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages
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 .


#2
420

420
  • Members
  • 190 messages
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

#3
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages
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 .


#4
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages
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?

#5
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages
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 :(

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 .


#6
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
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 .


#7
Mudeye

Mudeye
  • Members
  • 126 messages
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 .


#8
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages
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!

#9
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages
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 .


#10
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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 .


#11
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

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.

#12
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

  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.


 

#13
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
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.

#14
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages
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 .


#15
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
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.

#16
Mudeye

Mudeye
  • Members
  • 126 messages
Scripting or any kind of programming can be very frustrating. Also, attention to detail is really really important.

When restarting helps it might mean that you didn't get the new version loaded. One way this happens to me is that I save a script but forget to save the module and then test. The fix doesn't work because it isn't there. I have to go back to save the module to make it work.  It's really easy to miss a step.

Modifié par Mudeye, 17 novembre 2010 - 07:08 .


#17
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages
I automatically receive a "Save Tutorial" gump as soon as I hit the F9 button or exit out and have been doing everything right, as far as I know.

The link to the other tutorial:
http://nwvault.ign.c...r.Detail&id=803

It isn't the official one as I was thinking.

Here is the script I'm running. When I enter the first area, I have the module set a LocalInt on my PC and this script checks for it. For something like, "Speak String" it works just fine but it just doesn't destroy the NPC speaker for some reason. Everything else in there works fine, though.

#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);
if (GetLocalInt(oPC, "Vanish!")>= 3)
{
GuessWhatGoesHere
}
}

I've tried using these two:

oTarget = OBJECT_SELF;
DestroyObject(oTarget, 0.0);

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

I'd like to point out that if I just talk to a placed NPC and have him do this in conversation, the latter of the two above works fine. This only seems to be a problem if the NPC I'm attempting to "vanish" is/was a henchman.

I'm also receiving a message "You cannot have more than 1 Henchman at a time" when I run the script to add the NPC speaker to my party. I don't see why I should receive this error since he's the only one I'm adding. It might very well be one of the "and then re-write it, the previously written script is what runs instead of the new one" issue or something just as odd. It's not preventing me from continuing, though, so it's not a big deal.

Modifié par Werthers Chewbackas, 17 novembre 2010 - 07:15 .


#18
Mudeye

Mudeye
  • Members
  • 126 messages
How about trying this with a simplified script for the ActionsTaken script of a conversation node in the henchman's conversation that dismisses the henchman.  (make sure that the "APsychoticDruid" object is in the same area and not far off).

void main()
{
    object oPC = GetPCSpeaker();
    AddJournalQuestEntry("GrimCompanions", 2, oPC, TRUE, FALSE, TRUE);
    RewardPartyXP(1000, oPC, FALSE);
    object druid = GetObjectByTag ("APsychoticDruid");
    ActionForceMoveToObject ( druid );
    ActionDoCommand( DescroyObject(OBJECT_SELF) );
}

#19
_Knightmare_

_Knightmare_
  • Members
  • 643 messages

Werthers Chewbackas wrote...

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


That specific example is an occasion where you are calling on the blueprint to spawn in a creature that (prior to spawning it) does not exist yet in game. Once the creature has been spawned and now exists in game, then you would use it's Tag to reference the object.

Perhaps I should add in a short section about the different uses bewteen a Tag and a ResRef in my next tutorial update...

Modifié par _Knightmare_, 17 novembre 2010 - 10:05 .


#20
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
The Link you gave was to the TBP toolset manual, I use it often and find it one of my most usefull resources. I Have just finished doing a search of the PDF for the word "ResRef". Every use of it that i seen in the manual was used correctly.



The toolset manual, However, Does not nor has it ever claimed to cover scripting.

#21
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages

Mudeye wrote...
    object druid = GetObjectByTag ("APsychoticDruid");
    ActionForceMoveToObject ( druid );
    ActionDoCommand( DescroyObject(OBJECT_SELF) );


I tried this and it wasn't successful unfortunately. The script I posted earlier is on the ActionsTaken box of the conversation node.

[Edit]
Fixed the spelling error, still nothing :(

As I said about the resref, it might be something strange with my computer. All I'm aware of is that I tried the first script listed in Knightmare's PDF using the resref of a red dragon and it did not work but did after I used that NPC's tag instead.

Modifié par Werthers Chewbackas, 17 novembre 2010 - 11:02 .


#22
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages
Tried throwing this on the OnHeartbeat script for him. Still nothing.

420 wrote...

if(GetAssociateType(OBJECT_SELF) != ASSOCIATE_TYPE_HENCHMAN)
{
ExecuteScript("destroyself", OBJECT_SELF);
}


Modifié par Werthers Chewbackas, 18 novembre 2010 - 02:37 .


#23
Werthers Chewbackas

Werthers Chewbackas
  • Members
  • 27 messages
Well, uh, looks like it works now.



void main()

{ RemoveHenchman( GetMaster() );

SetIsDestroyable( TRUE, FALSE );

DestroyObject( OBJECT_SELF );

}



Heh. Thanks for everybody's assistance. I might be back on here in the future if I feel like making anything a little more complex.