Author Topic: Help with Henchman  (Read 2069 times)

Legacy_HugoLuman

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Help with Henchman
« on: August 17, 2010, 11:00:09 am »


               Okay, so I have this henchman in my mod:

Name: Mordecai
class: Fighter
Alignment: Chaotic Evil
Appearance: Curst Swordsman
Race: Half-Elf
Gender: Male

The problem is, he won't level up. He is using all the SOU henchman scripts, which the tutorial says should work. Help?
               
               

               
            

Legacy_Luspr

  • Jr. Member
  • **
  • Posts: 78
  • Karma: +0/-0
Help with Henchman
« Reply #1 on: August 17, 2010, 01:30:51 pm »


               How are you trying to level him up?
               
               

               
            

Legacy_HugoLuman

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Help with Henchman
« Reply #2 on: August 17, 2010, 05:54:21 pm »


               He's supposed to auto-levelup when the player levels up. Is putting "Mordecai Level x" in his comments tab important? I notice that there are several copies of the default henchmen like that
               
               

               
            

Legacy_HugoLuman

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Help with Henchman
« Reply #3 on: August 17, 2010, 08:42:19 pm »


               Ok, now he levels up, but only if you fire him and re-hire him. How do I get him to auto-level?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help with Henchman
« Reply #4 on: August 17, 2010, 09:04:18 pm »


               Do you have a conversation attached to your henchman?

Most of the henchmen I remember level when you talk to them and ask them to level up.

I guess you could auto level them when you level your self. That would still take some extra code being added to the modules OnPCLevelUp Event.

Leveling up aof a henchman is done with the LevelUpHenchman Function

// Levels up a creature using default settings.
// If successfull it returns the level the creature now is, or 0 if it fails.
// If you want to give them a different level (ie: Give a Fighter a level of Wizard)
// you can specify that in the nclass.
// However, if you specify a class to which the creature no package specified,
// they will use the default package for that class for their levelup choices.
// (ie: no Barbarian Savage/Wizard Divination combinations)
// If you turn on bReadyAllSpells, all memorized spells will be ready to cast without resting.
// if nPackage is PACKAGE_INVALID then it will use the starting package assigned to that class or just the class package
int LevelUpHenchman( object oCreature, int nclass = class_TYPE_INVALID, int bReadyAllSpells = FALSE, int nPackage = PACKAGE_INVALID)

Your Question may get better answers if you posted it in the scripting forum. 
               
               

               


                     Modifié par Lightfoot8, 17 août 2010 - 08:07 .
                     
                  


            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Help with Henchman
« Reply #5 on: August 17, 2010, 09:06:59 pm »


               Is your companion Level 1 to start? Then they will level up when they join to meet your current level.

This could be why they only level when you fire them and rejoin. I think the SOU system reverts fired companions back to level 1 so they can be properly leveled up when they rejoin the PC.

FP!
               
               

               


                     Modifié par Fester Pot, 17 août 2010 - 08:07 .
                     
                  


            

Legacy_HugoLuman

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Help with Henchman
« Reply #6 on: August 18, 2010, 03:12:09 am »


               Yeah, he's level 1. He levels when he joins up, but firing/rehiring to level up is not something I want to do. Asking him to level up through dialogue does not work for some reason, even though I am using the correct script.
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Help with Henchman
« Reply #7 on: August 21, 2010, 06:56:41 pm »


               

HugoLuman wrote...

Yeah, he's level 1. He levels when he joins up, but firing/rehiring to level up is not something I want to do. Asking him to level up through dialogue does not work for some reason, even though I am using the correct script.

It would help if you posted the script you are using in the conversation.

I use a Heartbeat script on my server's henchmen to check the PC's level and level up to that if they are below that level.

-420
               
               

               
            

Legacy_HugoLuman

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Help with Henchman
« Reply #8 on: August 21, 2010, 08:17:03 pm »


               Wait I got the script to work. It would be nice if the henchman leveled up automatically, bu the conversation option now works fine. I am using the x0 henchman scripts and the x2 henchman death script
               
               

               
            

Legacy_420

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Help with Henchman
« Reply #9 on: August 22, 2010, 01:35:16 am »


               

HugoLuman wrote...

Wait I got the script to work. It would be nice if the henchman leveled up automatically, bu the conversation option now works fine. I am using the x0 henchman scripts and the x2 henchman death script

Here is the code I use in the henchman's OnHeartbeat script:

if(GetHitDice(OBJECT_SELF) < GetHitDice(GetMaster()))
    {
    int nHD = GetHitDice(GetMaster()) - GetHitDice(OBJECT_SELF);
    while(nHD > 0)
        {
        LevelUpHenchman(OBJECT_SELF, class_TYPE_INVALID, TRUE, PACKAGE_INVALID);
        nHD = nHD-1;
        }
    }

I also use this code in OnHeartbeat to clean up any henchman that have been removed from the party:

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

-420

EDIT: The "destroyself" script simply sets the object to destoyable then destroys it.
               
               

               


                     Modifié par 420, 22 août 2010 - 06:51 .
                     
                  


            

Legacy_HugoLuman

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Help with Henchman
« Reply #10 on: September 06, 2010, 04:26:32 am »


               That is good to know. I shall clean up my henchman's scripts, then.
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Help with Henchman
« Reply #11 on: October 08, 2010, 06:49:03 pm »


               The way I make henchmen keep leveled up is to make my own module level up script.  It is called OnPlayerLevelUp.  It just grabs all the PCs henchmen and levels them up.  You can even make it do things like multiclassing if you like.  I made a conversation option for the Henchman so you can tell them how you want them to train when they level up and then set the name of the level up package you want them to use as a local variable on the NPC.  The OnPlayerLevelUp script checks for that on the Henchman and uses that as the package for leveling up.

Also, the heartbeat scripts fire every 6 seconds so if you use them too much it can cause a lot of lag.  The OnPlayerLevelUp only happens when a player actually levels up.
               
               

               


                     Modifié par Mudeye, 08 octobre 2010 - 05:49 .
                     
                  


            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
Help with Henchman
« Reply #12 on: October 08, 2010, 11:02:38 pm »


               Q. What if the PC does not have their henchman with them when they level up?

With 420's script you could add a line at the top which checks to see if the hd of the pc equals the hd of the npc henchman then return the script if that statement is true.  That may save some checks though the while loop only executes if there is a difference in levels.  Not sure if that would save cpu cycles or not. 
Though the level up idea is fine as long as the players know that it only works if the henchman is in party when the pc levels up.  I could envision other problems with this method though, such as:  You just made a level and meet someone who offers to join your party, well you can't level them to your level until you level up, so here the conversation option would be a neccessity. 
               
               

               


                     Modifié par ffbj, 08 octobre 2010 - 10:10 .
                     
                  


            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Help with Henchman
« Reply #13 on: October 09, 2010, 06:36:55 pm »


               I have a script to level a new henchman when you take them on.  When they become your henchman they level up.  There is an on level up event for the PC where the other script is.  It will level up any henchmen you already have.  If you ever take a new henchman it gets leveled up automatically.  The existing henchmen get leveled up whenever you do. They don't have to be near you or anything.



The issue I have with 420's script is that it runs every 6 seconds no matter what.  If you make a lot of heartbeat scripts you can count on your system lagging down.
               
               

               
            

Legacy_Mudeye

  • Full Member
  • ***
  • Posts: 238
  • Karma: +0/-0
Help with Henchman
« Reply #14 on: October 09, 2010, 06:55:51 pm »


               Here are  a couple of scripts for leveling up henchmen. 
I level them up to the same level as the PC.  If you want them to be 2 levels lower
OnPCLevelUp then change:    while( hlvl < mlvl && hlvl!=0 )
to be:    while( hlvl < mlvl - 2 && hlvl!=0 )
in the second script.  All henchmen must start out as level 1.
When you add them they level up to match the PC.  You can set a local string on the NPC to a class package id and that will be used for leveling the henchman instead of the default if you want.
 

void main()
{
    object pc = GetPCLevellingUp();
    int mxHench = GetMaxHenchmen();
    int i;
    object hench;
    int lvl=0;
    for( i=0; i<mxHench; i++ )
    {
        hench = GetHenchman( pc, i+1 );
         //look for a levelclass id on the henchman  if it has been set
         //it will be a package name for leveling

        int cls = GetLocalInt( oHenchman, "levelclass");
          //if it wasn't set then we just use the invalid which uses default class

        if( cls == 0 )
        {
            cls = class_TYPE_INVALID;
        }
        if( hench != OBJECT_INVALID )
        {
           lvl = LevelUpHenchman(  hench, cls  );
           //you can put tests here to make sure the henchman leveled up.
        }
    }
}

Below is the add henchman script that I used for actions taken when you take on a henchman.
It goes in the conversation as the ActionsTaken script

#include "NW_I0_GENERIC"
#include "x0_i0_assoc"
void main()
{
    object oSpeaker = GetPCSpeaker();
    object oHenchman = OBJECT_SELF;
    AddHenchman(oSpeaker, oHenchman);

              //flag to remember that this NPC was once a henchman
    string hname = GetTag( OBJECT_SELF ) + "washench"; 
    SetLocalInt( oSpeaker, hname, 1 );

          //set the desired NPC behaviors
    SetAssociateState(NW_ASC_DISTANCE_2_METERS, TRUE);
    SetAssociateState(NW_ASC_DISTANCE_4_METERS, FALSE);
    SetAssociateState(NW_ASC_DISTANCE_6_METERS, FALSE);
    SetAssociateState(NW_ASC_MODE_DEFEND_MASTER);

          //level up the henchman
    int i;
    int mlvl=0;
    int nlvl = 0;
    mlvl = GetHitDice(oSpeaker);
    nlvl = GetHitDice(oHenchman);
    int hlvl= GetHitDice(oHenchman);

          //look for a levelclass id on the henchman  if it has been set it will be a package name for leveling
    int cls = GetLocalInt( oHenchman, "levelclass");
          //if it wasn't set then we just use the invalid which goes to the default class
    if( cls == 0 )
    {
        cls = class_TYPE_INVALID;
    }
          //now level up the henchman in the specified class
    while( hlvl < mlvl && hlvl!=0 )
    {
        hlvl = LevelUpHenchman( oHenchman, cls );
    }

}
               
               

               


                     Modifié par Mudeye, 09 octobre 2010 - 05:58 .