Set Max Henchmen Script?
Muttley
Member Posts: 65
I am trying to change the max henchmen in my module to more than one. I have managed to hire henchmen. But When i hire a 2nd the other one leaves the part automatically. I thought I had set the on module load script right but it still wont work, Here is the hire and load scripts below. Any help is much appreciated.
This is the load script...
// Example code for On Module Load to make the maximum
// number of henchmen 3
void main()
{
// No parameter other then a number needed
SetMaxHenchmen(3);
// Thats it!
}
And the hire script...
// * script: can_pay100
// * Does the PC have 100 gp?
// Use in [Text Appears When] tab of PC hiring dialog line.
#include "NW_I0_PLOT"
int StartingConditional()
{
return (HasGold(100,GetPCSpeaker()));
}
This is the load script...
// Example code for On Module Load to make the maximum
// number of henchmen 3
void main()
{
// No parameter other then a number needed
SetMaxHenchmen(3);
// Thats it!
}
And the hire script...
// * script: can_pay100
// * Does the PC have 100 gp?
// Use in [Text Appears When] tab of PC hiring dialog line.
#include "NW_I0_PLOT"
int StartingConditional()
{
return (HasGold(100,GetPCSpeaker()));
}
0
Comments
No doubt the problem is there - it's removing the existing henchman when the new one is hired.
With multiple henchmen, you need to remove that code.
Instead, the conditional script needs to decide up front whether hiring is permissible, and, if not, give the player the choice of which henchman to remove.
What it needs to do first is count the number of henchmen (a loop through GetFirstHenchman / GetNextHenchman, not counting horses (HorseGetIsAMount) if they are allowed in your module).
Compare that count with GetMaxHenchmen.
If there are fewer than the maximum, return TRUE to allow hiring, otherwise return FALSE.
The simplest way to handle the FALSE is for the NPC speaker to say "you have too many henchmen already", leaving it up to the player to remove a henchman before trying again (either through dialogue you have provided, or the radial menu).
Alternatively, you can give the player conditional dialogue lines e.g. "Remove Anna", "Remove Bert" etc for each of the existing henchmen, each with an Action Taken that removes the selected henchman and hires the new one.
// * script: henchman_joins
// * NPC Henchman joins PC, replacing other henchman if necessary.
// Use in [Actions Taken] tab of henchman's joining dialog line.
#include "nw_i0_henchman"
void main()
{
if (GetIsObjectValid(GetHenchman(GetPCSpeaker())) == TRUE)
{ SetFormerMaster(GetPCSpeaker(), GetHenchman(GetPCSpeaker()));
object oHench = GetHenchman(GetPCSpeaker());
RemoveHenchman(GetPCSpeaker(), GetHenchman(GetPCSpeaker()));
AssignCommand(oHench, ClearAllActions());
}
SetWorkingForPlayer(GetPCSpeaker());
SetBeenHired();
ExecuteScript("NW_CH_JOIN", OBJECT_SELF);
}
Now the number of henchmen will be unlimited in the Action Taken, so you need to check whether hiring is permissible first, as previously explained.