PDA

View Full Version : move npc script


DarthStoney
04-25-2007, 08:01 AM
I need help with a little script it is for TSL. I am trying to get an npc to
come towards my character and start a conv. everything works except
the npc does not move. Have even tried adding a specific waypoint for
him to move to with no success. this is the script I am using.

void main() {
object oEntering = GetEnteringObject();
object oPC=GetFirstPC();
object oKaah = GetObjectByTag("Kaah", 0);
AssignCommand(oKaah, ClearAllActions());
AssignCommand((GetObjectByTag("Kaah")),ActionMoveToObject(oPC));
AssignCommand(oKaah, ActionStartConversation(GetFirstPC(), "", 0, 0, 0, "", "", "", "", "", "", 0));
DestroyObject(OBJECT_SELF);
}

tk102
04-25-2007, 11:54 AM
object oEntering = GetEnteringObject();
You should use the GetEnteringObject function to check whether the object is a player controlled character so some other object doesn't trip the script. Also you might want to make sure you are using an uppercase K in your .utc's Tag field. (I'd recommend always use lowercase so you don't have to try to remember when it comes time to script.)

Try this instead. You can remove the SendMessageToPC lines after you're done debugging. :)
void main() {
object oPC=GetFirstPC();
SendMessageToPC(oPC,"DEBUG: My script has fired"); //optional debug line
if (GetEnteringObject() != oPC) {
return;
}
SendMessageToPC(oPC,"DEBUG2: PC has entered"); //optional debug line
object oKaah = GetObjectByTag("Kaah");
if (!GetIsObjectValid(oKaah)) {
SendMessageToPC(oPC,"DEBUG: Eek, could not find Kaah!");
return;
}
SendMessageToPC(oPC,"DEBUG3: Telling Kaah to come here and talk to me"); //optional
AssignCommand(oKaah, ClearAllActions());
AssignCommand(oKaah, ActionMoveToObject(oPC));
AssignCommand(oKaah, ActionStartConversation(oPC));
SendMessageToPC(oPC,"DEBUG4: Destroying trigger object"); //optional
DestroyObject(OBJECT_SELF);
}

DarthStoney
04-25-2007, 02:56 PM
Okay I will try this script. thankyou. The other question is am I using it properly by
running it from a trigger?

tk102
04-25-2007, 03:01 PM
Yes. Just make sure the script name is located in the ScriptOnEnter field of the .utt.

DarthStoney
04-27-2007, 09:33 AM
Well I got all that working now I just need to know if there is a simple script
for having the NPC commit suicide?

Prime
04-27-2007, 11:39 AM
Meaning what exactly? Disappear? Fall down?

Master Zionosis
04-27-2007, 12:11 PM
I think he means like what Visas can do on the Ravager, though i thought only She had the animations to do that, but i would just use a script that makes them hold their heart and fall to the floor face down, not sure what the script is at the moment though, I've never used it, only seen it.

stoffe
04-27-2007, 12:35 PM
If you just want them to fall over and die a simple script like this should work:


void main() {
object oVictim = GetObjectByTag("DeadAsADoorNail");
AssignCommand(oVictim, SetIsDestroyable(FALSE));
AssignCommand(oVictim, PlayAnimation(ANIMATION_LOOPING_CHOKE_WORKING, 1.0, 0.5));
DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oVictim));
}

DarthStoney
04-27-2007, 01:55 PM
yep that is excactly what I was looking for thank you.