PDA

View Full Version : Henchmen scripts for the sake of...Henchmen Scripts


Dak Vesser
09-21-2005, 03:42 PM
Hey there everybody. It’s been awhile since I’ve been in the H-Laboratory and off course, for my come back, thought I’d be so bold as to start a thread just for sharing our killer custom “Henchmen” scripts to each other here in the modding community. So if anyone here who knows how to, make custom henchmen script, post them here. If you want to learn scripting, you can look in the tutorial section of this forum, unless the administrators actually wanna put this thread in the tutorial section.

So anyways, I’ll start this off with a new custom heartbeat script I created for my next -Holo- Droid, coming out soon. This script is NOT meant for a character that you want to add as a party member. Instead, the routines are setup for what I like to call a “Fake Party Member” which is someone who will follow but is not assign to the party table, therefore cannot be selected to take lead.


#include "k_inc_debug"
#include "k_inc_generic"
#include "k_inc_switch"
#include "k_inc_utility"



void main()
{



object oEnemy = GetNearestCreature(CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN, OBJECT_SELF, 1, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY);
if(!GN_GetSpawnInCondition(SW_FLAG_AI_OFF) && !GetSoloMode())
{
if(GetPartyMemberByIndex(0) != OBJECT_SELF)
{
if(//GetCurrentAction(OBJECT_SELF) != ACTION_FOLLOW &&
GetCurrentAction(OBJECT_SELF) != ACTION_WAIT &&
!GetIsConversationActive() &&
!GN_GetSpawnInCondition(SW_FLAG_SPECTATOR_STATE) &&
GetCommandable())
{

if(!GN_GetIsFighting(OBJECT_SELF) && !GetIsObjectValid(oEnemy))


ClearAllActions();
if(GetDistanceBetween(OBJECT_SELF, GetPartyMemberByIndex(0)) < 5.0)
{
ClearAllActions();
ActionForceMoveToObject(GetPartyMemberByIndex(0), FALSE, 1.0);
//SendMessageToPC(GetFirstPC(), "Debug Message: Henchmen just executed the bWalk routine.");
}
if(GetDistanceBetween(OBJECT_SELF, GetPartyMemberByIndex(0)) > 5.0)
{
ClearAllActions();
ActionForceMoveToObject(GetPartyMemberByIndex(0), TRUE, 3.5);
//SendMessageToPC(GetFirstPC(), "Debug Message: Henchmen just executed the bRun routine.");
}

}
}
}
else if(GetSoloMode() && GetCurrentAction(OBJECT_SELF) == ACTION_FOLLOWLEADER)
{
ClearAllActions();
}
if(GN_GetSpawnInCondition(SW_FLAG_EVENT_ON_HEARTBE AT))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1001));
}



}



This next one I created is an On Blocked Script. Added "Picked Lock Routine" for the Holo Droid just in case a locked door gets in its Pathway, it can unlock or attempt to unlock and open it. That way, the player won't have to Deactivate/reactivate the droid to get it back to within float range.

The reason for this is because when I added the “PC Location Jump” options in the planetary Debug section of the "g_cheatbot01" dialogue, I needed to make sure the Holo Droid could follow and or catch up.

#include "k_inc_debug"
#include "k_inc_generic"
#include "k_inc_switch"
#include "k_inc_utility"

void main()
{
object oDoor = GetBlockingDoor();
if(!GN_GetSpawnInCondition(SW_FLAG_AI_OFF))
{
if(GetAbilityScore(OBJECT_SELF, ABILITY_INTELLIGENCE) >= 5)
{
if(GetIsDoorActionPossible(oDoor, DOOR_ACTION_OPEN) &&
GetAbilityScore(OBJECT_SELF, ABILITY_INTELLIGENCE) >= 7 )
{
DoDoorAction(oDoor, DOOR_ACTION_OPEN);
SendMessageToPC(GetFirstPC(), "Debug Message: Henchmen just executed the -door open- routine...");
}
if(GetLocked(oDoor))
{
DoDoorAction(oDoor, DOOR_ACTION_UNLOCK);
SendMessageToPC(GetFirstPC(), "Debug Message: Henchmen just executed the -picked lock- routine...");
}
else if(GetIsDoorActionPossible(oDoor, DOOR_ACTION_BASH))
{
DoDoorAction(oDoor, DOOR_ACTION_BASH);
SendMessageToPC(GetFirstPC(), "Debug Message: Henchmen just executed the -door bash- routine...");
}
}
}
if(GN_GetSpawnInCondition(SW_FLAG_EVENT_ON_BLOCKED ))
{
SignalEvent(OBJECT_SELF, EventUserDefined(1009));
}
}


This is a good script if you wanna create a creature with a custom pathway through a locked door..

Darth333
09-21-2005, 03:51 PM
Thanks for sharing this Dak! This could come in handy for those who are making side quests. However, some colors are pretty hard to read (especially the dark blue and the red). I'll add it to the tuts.

Dak Vesser
09-21-2005, 04:09 PM
Thanks for sharing this Dak! This could come in handy for those who are making side quests. However, some colors are pretty hard to read (especially the dark blue and the red). I'll add it to the tuts.

You're right, It was hard to read. lol
I just re-edited it without all the fancy colors..

Lando Griffin
09-21-2005, 09:41 PM
when u say henchman, u mean they follow the pc character or other npc in the game?

Dak Vesser
09-21-2005, 10:35 PM
Here’s a really cool Heartbeat script, I just created. I call it “The Shape Shifter”.
Basically it makes the Henchmen do a random appearance change using the RollDice method equaling to d10(1). I also added a fire effect for every time it changes. I created two versions, one for the “Fake Party Member”, and the other, for the “Real Party Member”. This first Script switches from 10 different droids, and the second script switches from 10 different organics. But of course you can change'em to what ever you want..

For the “Fake Party Member” or the creature that’s going to follow the one in lead;


#include "k_inc_debug"
#include "k_inc_generic"
#include "k_inc_switch"
#include "k_inc_utility"


int iRollDice = d10(1); //From 1-10, what number will the dice land on? Well, It's up to the game engine now.
void main()
{



effect eBlind = EffectVisualEffect(VFX_PRO_DRAIN);
object oEnemy = GetNearestCreature(CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN, OBJECT_SELF, 1, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY);
if(!GN_GetSpawnInCondition(SW_FLAG_AI_OFF) && !GetSoloMode())
{
if(GetPartyMemberByIndex(0) != OBJECT_SELF)
{
if(GetCurrentAction(OBJECT_SELF) != ACTION_FOLLOW &&
GetCurrentAction(OBJECT_SELF) != ACTION_MOVETOPOINT &&
GetCurrentAction(OBJECT_SELF) != ACTION_WAIT &&
!GetIsConversationActive() &&
!GN_GetSpawnInCondition(SW_FLAG_SPECTATOR_STATE) &&
GetCommandable())
{

if(!GN_GetIsFighting(OBJECT_SELF) && !GetIsObjectValid(oEnemy))


ClearAllActions();
if(GetDistanceBetween(OBJECT_SELF, GetPartyMemberByIndex(0)) > 4.0)
{
ClearAllActions();
ActionForceMoveToObject(GetPartyMemberByIndex(0), TRUE, 4.0);
//SendMessageToPC(GetFirstPC(), "Debug Message: -Holo- Droid just executed the bRun routine.");
}
if(GetDistanceBetween(OBJECT_SELF, GetPartyMemberByIndex(0)) < 4.0)
{
ClearAllActions();
ActionForceMoveToObject(GetPartyMemberByIndex(0), FALSE, 2.0);
//SendMessageToPC(GetFirstPC(), "Debug Message: -Holo- Droid just executed the bWalk routine.");
}
if(d100(1) > 51) //50% Chance of a random switch, meaning how fast.
{

switch(iRollDice) //Generated Number
{
case 1:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 64));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 1 is now Active: Droid_Sentry transformation.");
break;
case 2:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 57));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 2 is now Active: Droid_Astro_01 transformation.");
break;
case 3:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 59));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 3 is now Active: Droid_Mark_Four transformation.");
break;
case 4:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 60));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 4 is now Active: Droid_Mark_One transformation.");
break;
case 5:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 65));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 5 is now Active: Droid_Spyder transformation.");
break;
case 6:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 61));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 6 is now Active: Droid_Mark_Two transformation.");
break;
case 7:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 538 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 7 is now Active: Droid_NPC_hk50 transformation.");
break;
case 8:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 581));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 8 is now Active: Droid_Mining_Mark_Two_B transformation.");
break;
case 9:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 630));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 9 is now Active: Droid_MineFloating transformation.");
break;
case 10:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 555));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBlind, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 10 is now Active: Droid_Construction_Medium transformation.");
break;
}

}
}
}
}
else if(GetSoloMode() && GetCurrentAction(OBJECT_SELF) == ACTION_FOLLOWLEADER)
{
ClearAllActions();
}
if(GN_GetSpawnInCondition(SW_FLAG_EVENT_ON_HEARTBE AT))//Close this gap so it reads _HEARTBEAT!!!
{
SignalEvent(OBJECT_SELF, EventUserDefined(1001));
}



}



For the “Real Party Member” or the creature that’s going to be added to the Party table;

#include "k_inc_debug"
#include "k_inc_generic"
#include "k_inc_switch"
#include "k_inc_utility"


int iRollDice = d10(1); //From 1-10, what number will the dice land on? Well, It's up to the game engine now.
void main()
{
effect eFire = EffectVisualEffect(VFX_PRO_DRAIN);//Gives a Fire Glow effect on switching.
object oEnemy = GetNearestCreature(CREATURE_TYPE_PERCEPTION, PERCEPTION_SEEN, OBJECT_SELF, 1, CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY);
if(!GN_GetSpawnInCondition(SW_FLAG_AI_OFF) && !GetSoloMode())
{
if(GetPartyMemberByIndex(0) != OBJECT_SELF)
{
if(IsObjectPartyMember(OBJECT_SELF) &&
//GetCurrentAction(OBJECT_SELF) != ACTION_FOLLOW &&
GetCurrentAction(OBJECT_SELF) != ACTION_MOVETOPOINT &&
//GetCurrentAction(OBJECT_SELF) != ACTION_WAIT &&
GetCurrentAction(OBJECT_SELF) != ACTION_FOLLOWLEADER &&
!GetIsConversationActive() &&
//GetDistanceBetween(OBJECT_SELF, GetPartyMemberByIndex(0)) > 4.5 &&
!GN_GetSpawnInCondition(SW_FLAG_SPECTATOR_STATE) &&
GetCommandable())
{
if(!GN_GetIsFighting(OBJECT_SELF) && !GetIsObjectValid(oEnemy))
{

ClearAllActions();
ActionFollowLeader();

if(d100(1) > 21) //80% Chance of a random switch, meaning how fast.
{
switch(iRollDice) //Generated Number
{
case 1:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 653 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 1 is now Active: Twilek_Assasin_02 transformation.");
break;
case 2:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 22 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 2 is now Active: Unique_Darth_Revan transformation.");
break;
case 3:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 52 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 3 is now Active: Unique_Vandar transformation.");
break;
case 4:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 79 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 4 is now Active: Creature_Rakghoul transformation.");
break;
case 5:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 249 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 5 is now Active: Creature_Kath_Hound_B03 transformation.");
break;
case 6:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 274 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 6 is now Active: Alien_Wookie_Male_05 transformation.");
break;
case 7:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 457 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 7 is now Active: Party_NPC_Visas transformation.");
break;
case 8:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 491 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 8 is now Active: Unique_Darth_Traya transformation.");
break;
case 9:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 458 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 9 is now Active: Unique_Darth_Sion transformation.");
break;
case 10:
ClearAllActions();
ActionDoCommand(ChangeObjectAppearance(OBJECT_SELF , 553 ));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, OBJECT_SELF, 1.0f);
//SendMessageToPC(GetFirstPC(), "Henchmen's Case 10 is now Active: Creature_Laigrek_01 transformation.");
break;
}
}

}
}
}
}
else if(GetSoloMode() && GetCurrentAction(OBJECT_SELF) == ACTION_FOLLOWLEADER)
{
ClearAllActions();
}
if(GN_GetSpawnInCondition(SW_FLAG_EVENT_ON_HEARTBE AT))// Close this gap so it reads as HEARTBEAT!!!
{
SignalEvent(OBJECT_SELF, EventUserDefined(1001));
}

}

Note: When you have two routines on top of one another in an AI script, such as: void ActionForceMoveToObject; to Move to the Object, and void Switch(iRollDice) to start the random Case switching, The Henchmen can only call for ONE Routine at a time - meaning, It can't move to the oObject and Switch appearances at the same time.. So If it is infact switching appearances then It won't move until a ClearAllActions() is called, or if the party leader moved into float range of the void ActionForceMoveToObject routine.

Also, The Odds of a Party Member Shape shifting is a little bit higher than the Non Party Script and that's because it's calling for the Void ActionFollowLeader(); Routine more often and ignores the Switching. But when it is Switching, then it's ignoring the Void ActionFollowLeader();..

Well, Hope you guys like these.

These scripts are using SWkoTOR II TSL Appearances.