Help needed - making a Henchman attack its Master?

Moderators: Nighthawk4, Dungeon Masters

Post Reply
User avatar
Calzier
CCC
CCC
Posts: 2051
Joined: Mon May 02, 2005 10:39 am
Timezone: GMT/BST
Location: UK

Help needed - making a Henchman attack its Master?

Post by Calzier » Wed Jul 30, 2008 10:17 pm

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... :evil: 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!

User avatar
Moredo
CCC
CCC
Posts: 7407
Joined: Mon May 26, 2003 3:47 pm
Timezone: +2
Location: Norway (GMT +2)

Re: Help needed - making a Henchman attack its Master?

Post by Moredo » Wed Jul 30, 2008 10:33 pm

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!

User avatar
Calzier
CCC
CCC
Posts: 2051
Joined: Mon May 02, 2005 10:39 am
Timezone: GMT/BST
Location: UK

Re: Help needed - making a Henchman attack its Master?

Post by Calzier » Wed Jul 30, 2008 10:37 pm

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...

User avatar
Moredo
CCC
CCC
Posts: 7407
Joined: Mon May 26, 2003 3:47 pm
Timezone: +2
Location: Norway (GMT +2)

Re: Help needed - making a Henchman attack its Master?

Post by Moredo » Wed Jul 30, 2008 11:05 pm

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();
}

User avatar
Calzier
CCC
CCC
Posts: 2051
Joined: Mon May 02, 2005 10:39 am
Timezone: GMT/BST
Location: UK

Re: Help needed - making a Henchman attack its Master?

Post by Calzier » Thu Jul 31, 2008 2:55 pm

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! :lol: )

scratch that.
Last edited by Calzier on Fri Aug 01, 2008 8:33 am, edited 1 time in total.

User avatar
Moredo
CCC
CCC
Posts: 7407
Joined: Mon May 26, 2003 3:47 pm
Timezone: +2
Location: Norway (GMT +2)

Re: Help needed - making a Henchman attack its Master?

Post by Moredo » Thu Jul 31, 2008 3:08 pm

Heh, I'm kinda interested, what is it you're trying to do. What is calling the script, ect?

User avatar
MadK@
Legacy DM
Legacy DM
Posts: 5207
Joined: Sat Feb 12, 2005 12:45 pm
Timezone: +8 GMT
DM Avatar: Xenon
Location: Perth Western Australia
Contact:

Re: Help needed - making a Henchman attack its Master?

Post by MadK@ » Thu Jul 31, 2008 4:17 pm

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);

}
___________
CoEMF CoAWP
Image _ Image

User avatar
Calzier
CCC
CCC
Posts: 2051
Joined: Mon May 02, 2005 10:39 am
Timezone: GMT/BST
Location: UK

Re: Help needed - making a Henchman attack its Master?

Post by Calzier » Fri Aug 01, 2008 8:42 am

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.

Post Reply