Jump to content

Home

Script help please


mjpb3

Recommended Posts

I am editing a dialog, and I need a script that will move an NPC forward maybe one or two steps towards the speaker (PC).

 

This is for K2 and the convo will take place on the Ebon Hawk,if that is needed.

 

Nothing too complicated, just move an NPC a step or two forward script... is that possible?

 

Thanks!

Link to comment
Share on other sites

This should work, should it compile (I don't have KotOR on my computer now so I can't test it), it should make the caller face the PC (meaning the NPC has to call the script), then move forward a little:

void main() {
vector vPC = GetPosition(GetFirstPC());
SetFacingPoint(vPC);

float fTmp    = GetFacing(OBJECT_SELF);
vector vSelf  = GetPosition(OBJECT_SELF);
vector vTmp   = Vector(cos(fTmp), sin(fTmp), 0.0f);
vector vFinal = vSelf + vTmp;

AssignCommand(OBJECT_SELF, ActionForceMoveToLocation(Location(vFinal, GetFacing(OBJECT_SELF)), 0, 30.0f));
}

Link to comment
Share on other sites

I am editing a dialog, and I need a script that will move an NPC forward maybe one or two steps towards the speaker (PC).

 

Nothing too complicated, just move an NPC a step or two forward script... is that possible?

 

I think something like this may work. I don't know how far two steps are in-game, so you may have to tweak the fDist variable a bit. It is in-game distance measured in meters.

 

void main() {
   float fDist = 0.5; // distance to move, in meters...

   SetFacingPoint(GetPosition(GetPCSpeaker()));
   float fFace = GetFacing(OBJECT_SELF);
   location lLoc = Location(GetPosition(OBJECT_SELF) + (AngleToVector(fFace) * fDist), fFace);
   ActionMoveToLocation(lLoc, FALSE);
}

Link to comment
Share on other sites

I use my move tag script:

//pa_move_tag

#include "k_inc_glob_party"
#include "k_inc_debug"
#include "k_inc_utility"

void main() {
string sWaypoint = GetScriptStringParameter(); // could be an object or waypoint' s tag   
int nNPC  = GetScriptParameter(1); // NPC_ see npc.2da
int nPC = GetScriptParameter(2); // (1) Brings PC, (0) does not
int iDelay=GetScriptParameter(3);//Delay before PC moves
int iRun = GetScriptParameter(4); //(1) =run 0=walk
int nLock = GetScriptParameter(5);// locks orientation in dialoge 

object oNPC;

   if (nNPC == NPC_PLAYER)
   	oNPC = GetFirstPC();
   else
    	oNPC = GetObjectByTag(GetNPCTag(nNPC));


   if (GetIsObjectValid(oNPC)) {
 if (nPC == 1){


AssignCommand(oNPC, ActionForceMoveToObject(GetObjectByTag(sWaypoint),iRun));
              	DelayCommand(IntToFloat(iDelay), AssignCommand(GetFirstPC(), ActionForceMoveToObject(GetObjectByTag(sWaypoint),iRun)));
SetLockOrientationInDialog(GetFirstPC(), nLock);
}

else {
AssignCommand(oNPC, ActionForceMoveToObject(GetObjectByTag(sWaypoint),iRun));
}

  	 }
}

Link to comment
Share on other sites

Thanks everyone. I got it going.

 

~Now, I just have to figure out how to make my NPC NOT look like he's lurching at my PC :lol:

 

(I am trying to make my NPC walk a step or two towards my PC during a conversation, and make it look like he is 'putting a comforting arm around her', but right now it looks like he is lurching at her to strangle her :D)

 

Anyway, thanks to you all!

Link to comment
Share on other sites

~Now, I just have to figure out how to make my NPC NOT look like he's lurching at my PC :lol:

 

You could apply an EffectMovementSpeedDecrease effect briefly to slow the NPCs movement animations down a bit to make them softer.

 

Try adding something like this into your script:

effect eSlow = EffectMovementSpeedDecrease(50);

ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSlow, OBJECT_SELF, 6.0);

Link to comment
Share on other sites

You could apply an EffectMovementSpeedDecrease effect briefly to slow the NPCs movement animations down a bit to make them softer.

 

Try adding something like this into your script:

effect eSlow = EffectMovementSpeedDecrease(50);

ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSlow, OBJECT_SELF, 6.0);

 

 

This works great stoffe:D

 

Only thing is, now he winds up walking all the way BEHIND her. :xp:

 

Also, what animation do you suggest I use to make it appear as if he is reaching out his hands? I tried using talkforceful, but that isn't working right. He looks like a maniac killer going for her neck :lol:

 

Thanks!

 

EDIT: Nevermind I got it exactly how I wanted it. Thanks everyone :D

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...