Hi LF, I need a script that makes the closest NPC to T3 run up to him and kick him then walk back to where they were before. I need to make sure it doesn't start a combat situation just simply run up to, play kick animation in T3's direction and walk back to last position. SImple. Thanks in advance.
~Xander
IIRC there is no animation for a kick I'm afraid.
Though if you choose another animation, or find the kick animation then you can use this script:
void main()
{
int iRun = TRUE; // Whether or not the NPC will run.
object oMove = GetObjectByTag("object_to_move");
location lMove = GetLocation(oMove);
oT3 = GetObjectByTag("t3m4");
AssignCommand(oMove, ActionMoveToObject(oT3, iRun, 5.0));
AssignCommand(oMove, ActionPlayAnimation(ANIMATION_*);
AssignCommand(oMove, ActionMoveToLocation(lMove, iRun);
}
This script should do. It uses one of the unarmed combat animation for the kick. If you don't like it you can try other values for the variable 'nKickAnimation' in the script. The values can be found in animations.2da. Unarmed combat animations start with "UC_" as description. Add 10000 to the row label.
#include "k_inc_glob_party"
object GetNearestNPC(object oTarget, int nRacialType = RACIAL_TYPE_ALL);
object GetNearestNPC(object oTarget, int nRacialType = RACIAL_TYPE_ALL) {
int i;
object oNPC;
float fRange = -1.0;
object oClosestNPC = OBJECT_INVALID;
for(i = 0; i < 12; i++) {
oNPC = GetObjectByTag(GetNPCTag(i));
if(GetIsObjectValid(oNPC) && oNPC != oTarget && GetRacialType(oNPC) == nRacialType) {
if(GetDistanceBetween(oNPC, oTarget) < fRange || fRange < 0.0) {
oClosestNPC = oNPC;
fRange = GetDistanceBetween(oNPC, oTarget);
}
}
}
return oClosestNPC;
}
void main() {
object oVictim = GetObjectByTag("t3m4");
// Get the humanoid NPC that is closest to T3.
object oKicker = GetNearestNPC(oVictim, RACIAL_TYPE_HUMAN);
// The location the NPC should return to after the kick.
location lCurrentLoc = GetLocation(oKicker);
// Animation number for the kick
int nKickAnimation = 10528;
AssignCommand(oKicker, ClearAllActions());
AssignCommand(oKicker, ActionForceMoveToObject(oVictim, TRUE)); // Move
AssignCommand(oKicker, ActionDoCommand(ActionPlayAnimation(nKickAnimation ))); // Kick
AssignCommand(oKicker, ActionDoCommand(ActionMoveToLocation(lCurrentLoc)) ); // Walk back
}
Thanks. But I need this for K1
Then you needed to state this in your OP, no? People can't read minds. -RH