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