Page 1 of 1
Help needed - making a Henchman attack its Master?
Posted: Wed Jul 30, 2008 10:17 pm
by Calzier
OK, so I've fought with this for at least.. what? a day and half? And I've run out of ideas. I can drop the henchman from the party, make them hostile (glow red), but can I get them to attack anything???
This is what I have:
Code: Select all
RemoveHenchman(oPC, oTarget);
ChangeToStandardFaction(oTarget, STANDARD_FACTION_HOSTILE);
DelayCommand(1.0, AssignCommand(oTarget, DetermineCombatRound()));
[or just DetermineCombatRound()]
Anyone got any ideas? I've tried a bunch of other stuff, but nothing seems to work...

It would seem that making a Henchman turn against its master should be almost a standard fantasy RPG staple that would warrant its own function!
Re: Help needed - making a Henchman attack its Master?
Posted: Wed Jul 30, 2008 10:33 pm
by Moredo
Haven't tried it, so bear with me:
Code: Select all
void main()
{
object oPC = GetPCSpeaker();
object oHench = OBJECT_SELF;
RemoveHenchman(oPC, oHench);
SetIsTemporaryEnemy(oPC);
DetermineCombatRound();
}
This is if the attack is prompted on a conversation node like:
PC: Hey!
Henchman: Yeah?
PC: Your mother is a dwarf!
Re: Help needed - making a Henchman attack its Master?
Posted: Wed Jul 30, 2008 10:37 pm
by Calzier
Already tried 'SetIsTemporaryEnemy', but that with a bunch of other code that I've now changed, so maybe worth another shot. I'll post the result...
Re: Help needed - making a Henchman attack its Master?
Posted: Wed Jul 30, 2008 11:05 pm
by Moredo
This works Calzier:
Code: Select all
#include "nw_i0_henchman"
#include "NW_I0_GENERIC"
void main()
{
SetFormerMaster(GetPCSpeaker(), OBJECT_SELF);
RemoveHenchman(GetPCSpeaker());
ClearAllActions();
SetIsTemporaryEnemy(GetPCSpeaker(), OBJECT_SELF);
DetermineCombatRound();
}
Re: Help needed - making a Henchman attack its Master?
Posted: Thu Jul 31, 2008 2:55 pm
by Calzier
Moredo wrote:This works Calzier:
Code: Select all
#include "nw_i0_henchman"
#include "NW_I0_GENERIC"
void main()
{
SetFormerMaster(GetPCSpeaker(), OBJECT_SELF);
RemoveHenchman(GetPCSpeaker());
ClearAllActions();
SetIsTemporaryEnemy(GetPCSpeaker(), OBJECT_SELF);
DetermineCombatRound();
}
Couldn't quite get this to work - maybe problems as the Henchman is not calling the script, so have to use AssignCommand etc.
Managed to make it work with SetEnemy() from nw_i0_plot, though, so hopefully all is well... further testing and tweaking await (oh the joys of scripting things NWN doesn't seem to want you to do!

)
scratch that.
Re: Help needed - making a Henchman attack its Master?
Posted: Thu Jul 31, 2008 3:08 pm
by Moredo
Heh, I'm kinda interested, what is it you're trying to do. What is calling the script, ect?
Re: Help needed - making a Henchman attack its Master?
Posted: Thu Jul 31, 2008 4:17 pm
by MadK@
script needs to go on the OnPerception event of the henchman
Not sure what your trying to do either so Im not sure if this would help or not.
Code: Select all
#include "nw_i0_generic"
void main()
{
object oPC = GetLastPerceived();
if (!GetIsPC(oPC)) return;
if (!GetLastPerceptionSeen()) return;
object oTarget;
oTarget=GetHenchman(oPC);
RemoveHenchman(oPC, oTarget);
oTarget = OBJECT_SELF;
AdjustReputation(oPC, oTarget, -100);
SetIsTemporaryEnemy(oPC, oTarget);
ActionAttack(oPC);
DetermineCombatRound(oPC);
}
Re: Help needed - making a Henchman attack its Master?
Posted: Fri Aug 01, 2008 8:42 am
by Calzier
Moredo wrote:Heh, I'm kinda interested, what is it you're trying to do. What is calling the script, ect?
What I want to do is have a henchman, summoned creature, react badly to the PC casting one or more particular spells - essentially turning on their former master.
So, the spell script run a check and if appropriate, instructs the NPC (the target) to attack the PC (the caster).
That's the idea at least. Best I've managed so far - with any consistency - is to make the NPC hostile and attack if attacked, but having them initiate combat is a problem. I've tried using AssignCommand to run ActionAttack & Det.Cmbt.nd, but results so far are inconsistent. I really want a generic code snippet that can force the target of the spell into acting, rather than individually edit particular NPCs, and maybe be used in different spell scripts.
I'm out of town next week, but I'll have another stab when I'm back.