Author Topic: Controlling henchmen?  (Read 519 times)

Legacy_MrKWMonk

  • Newbie
  • *
  • Posts: 46
  • Karma: +0/-0
Controlling henchmen?
« on: July 17, 2013, 01:51:32 am »


               I use and really like OHS.  I also like the granular control you can achieve in BG and NWN2 within a party.

Pls excuse me if this is a dopey qusetion as I don't know much about NWN modding at all... Could the familar mind control functionality be somehow applied to include controlling henchmen to some extent?


-kaos


ps - if there's already some form of henchy control other than leaving it to the voice commands and the the AI pls let me knwo!

'<img'>
               
               

               


                     Modifié par MrKWMonk, 17 juillet 2013 - 12:53 .
                     
                  


            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Controlling henchmen?
« Reply #1 on: July 18, 2013, 03:46:31 am »


               You can make an item that clears henchmen/familiar/summon/animal companion actions and assigns them to either attack a target if one is chosen or move to a location otherwise.  Fairly simple to make though it's not perfect by any means.
               
               

               
            

Legacy_Killmonger

  • Sr. Member
  • ****
  • Posts: 349
  • Karma: +0/-0
Controlling henchmen?
« Reply #2 on: July 18, 2013, 09:59:15 pm »


               <For all of us non-scripters>

Please,

Please do so

<Thanks in advance>
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Controlling henchmen?
« Reply #3 on: July 27, 2013, 04:35:58 am »


               This will hopefully be approved in the near future.

http://nwvault.ign.c....Detail&id=3885

Use this to control minions.

Targeting a creature will cause minions to attack it if hostile and move to its location if friendly or neutral (may be altered to attack neutrals, module dependent).

Targeting a location will cause minions to attempt to move to the location.

Rife with bugginess and odd behavior - general idea is simply to give some very rough control over minions.

/***
    Magical Master's Minion Control (MMMC)

    - Allows some semblance of control over henchmen, summons,
      animal companions, and familiars
    - Should be attached to an item's activate item (long range) or an instant feat
      like the player tools - default set-up is to work with an item and tag-based
      scripting for ease of use but can easily be modified
    - If targeted on a hostile creature, commands all minions to attack that creature
    - If targeted on a location, commands all minions to move to that location
    - If targeted on a friendly/neutral creature, commands all commands to move to
      that creature's location.  However, setting the "attackNeutral" variable to 1
      will cause minions to attack neutral creatures if neutral creatures are targeted

***/

#include "x2_inc_switches"

// Determines behavior when targeting a neutral creature.  Setting this to non-zero will
// cause minions to attack the neutral creature while zero will cause minions to move to
// the neutral creature
int attackNeutral = 0;

void main()
{
    int nEvent = GetUserDefinedItemEventNumber();

    switch (nEvent)
    {
        case X2_ITEM_EVENT_ACTIVATE:
            object oPC = GetItemActivator();
            object oTarget = GetItemActivatedTarget();
            FloatingTextStringOnCreature("Starting activate item", oPC, FALSE);

            // If we have a valid target, use that location, otherwise get the location
            location lTarget = GetLocation(oTarget);
            if (oTarget == OBJECT_INVALID)
            {
                lTarget = GetItemActivatedTargetLocation();
            }

            // Going to loop through members of the party
            object oMinion = GetFirstFactionMember(oPC, FALSE);
            while (GetIsObjectValid(oMinion))
            {
                // If the party member's master (or master's master for minion summons) is the PC, issue orders
                if (GetMaster(oMinion) == oPC || GetMaster(GetMaster(oMinion)) == oPC)
                {
                    FloatingTextStringOnCreature("Commanding " + GetName(oMinion), oPC, FALSE);
                    // Targeted on object
                    if (GetIsObjectValid(oTarget) && GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
                    {
                        // Attack enemies
                        if (GetIsEnemy(oTarget))
                        {
                            FloatingTextStringOnCreature("Attacking " + GetName(oTarget), oPC, FALSE);
                            AssignCommand(oMinion, ClearAllActions());
                            DelayCommand(0.25, AssignCommand(oMinion, ActionAttack(oTarget)));
                        }
                        // Attack or move to neutral depending on variable
                        else if (GetIsNeutral(oTarget))
                        {
                            if (attackNeutral)
                            {
                                FloatingTextStringOnCreature("Attacking " + GetName(oTarget), oPC, FALSE);
                                AssignCommand(oMinion, ClearAllActions());
                                DelayCommand(0.25, AssignCommand(oMinion, ActionAttack(oTarget)));
                            }
                            else
                            {
                                FloatingTextStringOnCreature("Moving to location", oPC, FALSE);
                                AssignCommand(oMinion, ClearAllActions());
                                DelayCommand(0.25, AssignCommand(oMinion, ActionForceMoveToLocation(lTarget, TRUE, 12.0)));
                            }
                        }
                        // Move to friendly targets
                        else
                        {
                            FloatingTextStringOnCreature("Moving to location", oPC, FALSE);
                            AssignCommand(oMinion, ClearAllActions());
                            DelayCommand(0.25, AssignCommand(oMinion, ActionForceMoveToLocation(lTarget, TRUE, 12.0)));
                        }
                    }
                    // Targeted on location
                    else
                    {
                        FloatingTextStringOnCreature("Moving to location", oPC, FALSE);
                        AssignCommand(oMinion, ClearAllActions());
                        DelayCommand(0.25, AssignCommand(oMinion, ActionForceMoveToLocation(lTarget, TRUE, 12.0)));
                    }
                }
                oMinion = GetNextFactionMember(oPC, FALSE);
            }
    }

    SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END);
}

               
               

               
            

Legacy_Killmonger

  • Sr. Member
  • ****
  • Posts: 349
  • Karma: +0/-0
Controlling henchmen?
« Reply #4 on: July 28, 2013, 08:16:39 pm »


               Coolio !
What took you a week would've taken me much longer to develop
Haven't had a chance to try this out yet, but it is a good step forward... Thank you!!
It is good that it utilises tag based scripting

Does it have a local effect or is it area/module wide?
Would it be very hard to modify it to affect nearby (friendly?) factions rather than just minions/henchmen
When targeting a friendly, (or a location) could the minions be set to defend the site?

There are many ramifications that a low level control system could offer (both for offensive and defensive strategies) It reminds me of the 2002 Genji's Art of War system. <updates? ;-) >
However, his excellent high level system was dependent on the use of detailed "shouts" through the field marshal listener. Your notion appears to be more mouse driven in a fire and forget methodology (Simpler, dialog/radial driven is better)

Thanks again for having a stab at it...
Keep it up
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Controlling henchmen?
« Reply #5 on: July 30, 2013, 12:24:22 am »


               Eh, for what it's worth, that only took me about an hour to actually do (maybe less) - I'm just short on time and didn't get a chance to actually do it for a week.

It currently affects every creature controlled by the PC or any creature controlled by the PC's minions (so if a henchman wizard summons a creature, it'll affect that too).

It would not be hard to modify it to affect nearby factions - you'd simply change the while loop or add another while loop with different conditions.

The minions can't really be set to defend since the default AI will make them come back to you and follow you unless in combat.  I haven't looked at the scripts, but it's probably in the heartbeat.  If you made it so the minions did not automatically try to follow you every heartbeat, then it could be used to make them defend, yes.  This also means that if you tell them to go to a location, they often won't even reach it (because the heartbeat makes them return to you).

The point of this was to make something very simple that could be easily imported and gave basic functionality.  If you want it improved you're going to probably have to change other scripts too.
               
               

               
            

Legacy_Nevercallmebyname

  • Full Member
  • ***
  • Posts: 164
  • Karma: +0/-0
Controlling henchmen?
« Reply #6 on: July 30, 2013, 03:12:24 am »


               Sounds like a cool way of turning NWN into a sort of RTS.
With the script expanded to include a faction and the heatbeat modified you could start moving around entire armies in defense of a castle.
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Controlling henchmen?
« Reply #7 on: July 30, 2013, 08:25:36 am »


               Well, if you use it on non-henchmen, they don't have a script to follow the PC, so you might not even need to modify the heartbeat.  But yes, this could fairly easily be expanded (could also make different items affect different NPCs - archers versus fighters versus mages or whatever).
               
               

               
            

Legacy_Nevercallmebyname

  • Full Member
  • ***
  • Posts: 164
  • Karma: +0/-0
Controlling henchmen?
« Reply #8 on: July 30, 2013, 09:58:48 am »


               I cant wait to see what can be done with this script.
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Controlling henchmen?
« Reply #9 on: July 31, 2013, 03:56:57 am »


               Well, I don't have any plans to do anything myself at the moment, but I'd be willing to modify it if people have specific requests.
               
               

               
            

Legacy_Nevercallmebyname

  • Full Member
  • ***
  • Posts: 164
  • Karma: +0/-0
Controlling henchmen?
« Reply #10 on: July 31, 2013, 08:17:08 am »


               Yeah I'm not about to use it either. I'm an RPGer and like NWN how it is.
That said I could try recreating the NWN2 campain in NWN1 and use your script to make runing crossroad keep that little bit more interesting?
Doubt I will though. Too many stories of my own to tell.
               
               

               
            

Legacy_WebShaman

  • Hero Member
  • *****
  • Posts: 1390
  • Karma: +0/-0
Controlling henchmen?
« Reply #11 on: August 01, 2013, 08:28:25 am »


               It would be nice to have this implemented into the OHS!!!  Perhaps an add-on for it?
               
               

               
            

Legacy_WebShaman

  • Hero Member
  • *****
  • Posts: 1390
  • Karma: +0/-0
Controlling henchmen?
« Reply #12 on: August 01, 2013, 09:40:36 am »


               BTW, the Stand your ground command will prevent your henchies from following you.  So having the ability to manually direct your henchies to place them tactically for an encounter is very nice!
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Controlling henchmen?
« Reply #13 on: August 02, 2013, 08:02:04 pm »


               A few things.

1, I uploaded v2 which fixed a few bugs I noticed and removed some debugging strings I had left in.

2, WebShaman's idea about telling them to stand their ground and THEN telling them to move to a location works very well - since they don't try to return to you.  However, it does seem to cause some spellcaster AI problems where spellcaster henchmen will only attack with physical weapons instead of spells if you tell them to hold location and then target an enemy with the control script.

3, I'd be perfectly fine with this being implemented into henchmen packs or whatever
               
               

               


                     Modifié par MagicalMaster, 02 août 2013 - 07:02 .
                     
                  


            

Legacy_OldMansBeard

  • Full Member
  • ***
  • Posts: 245
  • Karma: +0/-0
Controlling henchmen?
« Reply #14 on: August 02, 2013, 09:38:47 pm »


               If someone wants to modify the OHS to incorporate this, go right ahead.

I've been intending to remove all restrictions from the OHS - just haven't gotten round to it.

Consider this posting as an interim notice, if you like.

"OldMansBeard said, henceforth, you can do anything you like with the OHS".