Jump to content

Home

A script that makes a npc stop?


sekan

Recommended Posts

I want to add a hold position command to my Call of Aid mod but I don't know if it's possible. So could anyone tell me is it possible to add a stop command to a npc that have a follow script on heartbeat?

 

Thanks and take care

Link to comment
Share on other sites

I shall hazard a guess :p I am presuming this mod allows you to issue commands to certain NPCs and so this should allow you to stop your NPC and also allow you to Make them follow again.

 

For your "onHeartBeat" script you can use:

void main(){
object oSelf = OBJECT_SELF;
object oFollow = GetFirstPC(); //Else use, GetObjectByTag("tag");
if(GetLocalBoolean(oSelf, [color=red]15[/color])) //111 Being an "unused" boolean.
	AssignCommand(oSelf, ClearAllActions());
else
	AssignCommand(oSelf, ActionForceFollowObject(oFollow));
}

 

And for your "Stop" command, I assume a separate script.

void main(){
object oStop = GetObjectByTag("[color=red]tag_of_object[/color]"); //The tag of the object you are stopping.
SetLocalBoolean( oStop, 15, TRUE );
}

 

And your "Follow" command.

void main(){
object oStop = GetObjectByTag("[color=red]tag_of_object[/color]"); //The tag of the object you want to follow.
SetLocalBoolean( oStop, 15, FALSE );
}

 

---

 

Of course you could always just use this for stop:

void main(){
object oStop = GetObjectByTag("[color=red]tag_of_object[/color]"); //The tag of the object you are stopping.
AssignCommand(oStop, ClearAllActions());
}

 

And this for follow, so you can ditch the "onHeartBeat" script.

void main(){
object oStop = GetObjectByTag("[color=red]tag_of_object[/color]"); //The tag of the object you want to follow you.
AssignCommand(oSelf, ActionForceFollowObject(OBJECT_SELF));
}

 

I'm pretty sure they should both work, I haven't had much experience with local booleans but those indexes seem about right.

Have a look and see which ones are easier but there is always the chance I have presumed wrong :p.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...