GeorgNihilus Posted November 20, 2007 Share Posted November 20, 2007 Hi folks, I'm having a bothering issue with an NPC facing, I'm using this script to move back a soldier to a spot but when I want to face him to a specific direction he doesn't do anything ... it seems to be ignoring that facing last command. Here's the script: // moves back the Checkpoint Guard of Iziz merch quarter (Onderon) to an specific spot, // after having a dialog with the PC void main() { object oGUA=GetObjectByTag("cp_guard"); float x=6.64863f; float y=96.45885f; float z=12.7466f; float r=204.15610f; ActionDoCommand(SetCommandable(TRUE,oGUA)); DelayCommand(2.5, AssignCommand(oGUA, ActionMoveToLocation(Location(Vector(x,y,z), r)))); AssignCommand(oGUA, SetFacingPoint(Vector(-8.13,92.12,12.75))); //this line seems to be ignored } so ... the soldier is correctly placing himself where I want but not facing to the indicated vector in the last line ... thanks on advance Link to comment Share on other sites More sharing options...
stoffe Posted November 21, 2007 Share Posted November 21, 2007 Hi folks, I'm having a bothering issue with an NPC facing, I'm using this script to move back a soldier to a spot but when I want to face him to a specific direction he doesn't do anything ... it seems to be ignoring that facing last command. The problem is likely that ActionMoveToLocation() runs from the action queue, while SetFacingPoint() does not. Thus the facing is done immediately before the character starts moving, not when they arrive at the destination. Try this instead and see if it makes a difference. It adds the facing command to the action queue as well: void ST_Move() { SetCommandable(TRUE); ActionMoveToLocation(Location(Vector(6.65, 96.46, 12.75), 204.16)); ActionDoCommand(SetFacingPoint(Vector(-8.13, 92.12, 12.75))); } void main() { DelayCommand(2.5, AssignCommand(GetObjectByTag("cp_guard"), ST_Move())); } Link to comment Share on other sites More sharing options...
GeorgNihilus Posted November 21, 2007 Author Share Posted November 21, 2007 Very interesting ... thanks Stoffe works fine ... and by the way, where should I check to learn which functions run from the action queue and which don't? good modding! Link to comment Share on other sites More sharing options...
stoffe Posted November 22, 2007 Share Posted November 22, 2007 where should I check to learn which functions run from the action queue and which don't? The functions which add an action to the action queue of the object running them tend to have names starting with Action, like ActionMoveToObject() or ActionStartConversation(), whereas scripting functions that do things to an object directly do not have such a name prefix. You can wrap most scripting functions (even your own custom ones) with no return value in a ActionDoCommand() call to add their execution to the action queue of an object as well. The action queue is essentially a list of tasks the object should perform sequentially, one at a time, where it won't start on the next item in the list before it has finished with the current one. When you play the game and tell your characters to move, attack, start conversation etc you are also adding actions to the action queue of your characters. Link to comment Share on other sites More sharing options...
GeorgNihilus Posted November 24, 2007 Author Share Posted November 24, 2007 Alright, thanks for the tip. Good modding Link to comment Share on other sites More sharing options...
GeorgNihilus Posted December 3, 2007 Author Share Posted December 3, 2007 So ... now I'm trying to make 2 thugs walk at the same time to specific spots, problem is only one of them is actually walking, I'm using this script, which also spawns other thugs: // spawns 6 thugs in a hidden Security Center of Nar Shaddaa docks // near Fassa twi'lek and 'should' move 2 of them to certain spots #include "k_inc_debug" #include "k_inc_utility" void ST_Move() { // a devaronian thug SetCommandable(TRUE); ActionMoveToLocation(Location(Vector(9.84, 62.28, 8.64), 266.40)); } void ST_Move2() { // a female twi'lek merc SetCommandable(TRUE); ActionMoveToLocation(Location(Vector(27.85, 60.94, 8.643), 229.59)); } void main() { location locA = Location(Vector(2.147,54.92,8.64), 357.85); location locB = Location(Vector(-0.047,56.66,8.64), 341.26); location locC = Location(Vector(3.95,53.29,8.64), 0.45); location locD = Location(Vector(24.92,55.52,8.643), 180.01); location locE = Location(Vector(10.94,43.10,8.643), 2.032); location locG = Location(Vector(21.52,35.73,8.64), 122.733); CreateObject(OBJECT_TYPE_CREATURE, "n_compleadr", locA); CreateObject(OBJECT_TYPE_CREATURE, "n_compthug", locB); CreateObject(OBJECT_TYPE_CREATURE, "n_compthug2", locC); CreateObject(OBJECT_TYPE_CREATURE, "n_compthug3", locD); CreateObject(OBJECT_TYPE_CREATURE, "n_compthu4w", locE); CreateObject(OBJECT_TYPE_CREATURE, "n_compthug5w", locG); [color=DarkOrange]DelayCommand(4.5, AssignCommand(GetObjectByTag("n_compthug5w"), ST_Move2()));[/color] // this one is not walking DelayCommand(8.7, AssignCommand(GetObjectByTag("n_compthu4w"), ST_Move())); // this one is walking } Everything works except the indicated line in orange; I supposed the ActionMoveToLocation() function could be used simultaneously on different NPC's ... if that is the problem ... or is something else guys?? Thanks on advance Link to comment Share on other sites More sharing options...
stoffe Posted December 3, 2007 Share Posted December 3, 2007 So ... now I'm trying to make 2 thugs walk at the same time to specific spots, problem is only one of them is actually walking, I'm using this script, which also spawns other thugs: Make sure the tag is correctly corresponding to what is set in the UTC file for the second thug. If this is correct you could try to clear the action queue and issuing a forced move command instead, in case the NPC is doing ambient animations or something at the time. Like: object ST_Spawn(string sResRef, float x, float y, float fFace); void ST_Move(float x, float y, float fFace, object oActor = OBJECT_SELF); void main() { ST_Spawn("n_compleadr", 2.147, 54.92, 357.85); ST_Spawn("n_compthug", -0.047, 56.66, 341.26); ST_Spawn("n_compthug2", 3.95, 53.29, 0.45); ST_Spawn("n_compthug3", 24.92, 55.52, 180.01); object oThug1 = ST_Spawn("n_compthu4w", 10.94, 43.10, 2.032); object oThug2 = ST_Spawn("n_compthug5w", 21.52, 35.73, 122.733); DelayCommand(4.5, ST_Move(27.85, 60.94, 229.59, oThug2)); DelayCommand(8.7, ST_Move(9.84, 62.28, 266.40, oThug1)); } object ST_Spawn(string sResRef, float x, float y, float fFace) { return CreateObject(OBJECT_TYPE_CREATURE, sResRef, Location(Vector(x, y, 0.0), fFace)); } void ST_Move(float x, float y, float fFace, object oActor = OBJECT_SELF) { AssignCommand(oActor, SetCommandable(TRUE, oActor)); AssignCommand(oActor, ClearAllActions()); AssignCommand(oActor, ActionForceMoveToLocation(Location(Vector(x, y, 0.0), fFace))); } Also make sure there is a clear path between the start location and the destination. MoveToLocation will sometimes have trouble pathfinding around objects blocking its path. Link to comment Share on other sites More sharing options...
GeorgNihilus Posted December 3, 2007 Author Share Posted December 3, 2007 Problem was, indeed, a corner blocking the path of the twi'lek to its destination spot ... I changed it and worked fine ... thanks anyway for the additional script, I can use it for something else ... good modding! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.