Silveredge9 Posted July 13, 2006 Share Posted July 13, 2006 1. What script would I use to make an NPC stop at a specified waypoint for a certain amount of time and perhaps do a command (Like an animation or something) 2. How would I make an NPC wait for a certain amount of time at each waypoint instead of immediately moving on towards the next. 3. I've encountered a strange problem that happens during dialogue. When using certain sounds for aliens during dialogue, the mouths don't move on the npc's whilst with other sounds the mouths move. Like for example with the sound "N_GFTWILEK_COMS1" the mouths move on the NPC but with "N_GFTWILEK_GRTM" the mouth doesn't move. Thanks in advance for any help. Link to comment Share on other sites More sharing options...
Pavlos Posted July 13, 2006 Share Posted July 13, 2006 Hello there, SilverEdge9. 1) We're going to make our own OnUserDefined script for this: void main() { string sWP = (("wp_" + GetTag(OBJECT_SELF)) + "_0"); int nNumb = 1; object oWP = GetObjectByTag((sWP + IntToString(nNumb)), 0); ClearAllActions(); while (GetIsObjectValid(oWP)) { ActionMoveToObject(oWP, 0, 1.0); if (nNumb == 10) { //This is for waypoint 10 - change the number if needs be. ActionPlayAnimation(0, 1.0, 3.33); //Replace "0" with your animation index, plays an animation for 3.33 s } (nNumb++); oWP = GetObjectByTag((sWP + IntToString(nNumb)), 0); } //Seeing as how we don't have any other parts to our userdefined script we'll just stick with 0 ActionDoCommand(SignalEvent(OBJECT_SELF, EventUserDefined(0))); } 2) We can make use of "ActionWait(float fTime)" The float is your time in seconds . As it is a float we can have decimal places so we can have "ActionWait(7.0000112);" as a command. This would be placed outside of your "if" clause but within the "while" so that it affects all of the possibilities. 3) Not all of the modules have the full range of AVO lip synchs . Either go on a search for other lip synch from modules, create your own with JdNoa's handy tool, or use other lines. Hope this helped. Link to comment Share on other sites More sharing options...
stoffe Posted July 13, 2006 Share Posted July 13, 2006 1. What script would I use to make an NPC stop at a specified waypoint for a certain amount of time and perhaps do a command (Like an animation or something) 2. How would I make an NPC wait for a certain amount of time at each waypoint instead of immediately moving on towards the next. I have made some changes to the generic waypoint walking scripts for my own use earlier. Basically it lets you (optionally) set two (sets of) local number variables on each waypoint, which would specify how long the NPC would pause there, and the number of the animation (if any) to play while pausing there. This way it's handled generically along with the normal waypoint walking and won't require any custom scripts making them move around and animate. All that's needed is a custom OnSpawn script that enables animated waypoint walking, and sets the LocalNums on the waypoints. Seems to work fine here from what I have tested it. If you want it I could upload it, though it'd require you to recompile the AI scripts for your NPC for it to work, since it's an include file I've modified. Link to comment Share on other sites More sharing options...
Silveredge9 Posted July 13, 2006 Author Share Posted July 13, 2006 I have made some changes to the generic waypoint walking scripts for my own use earlier. Basically it lets you (optionally) set two (sets of) local number variables on each waypoint, which would specify how long the NPC would pause there, and the number of the animation (if any) to play while pausing there. This way it's handled generically along with the normal waypoint walking and won't require any custom scripts making them move around and animate. All that's needed is a custom OnSpawn script that enables animated waypoint walking, and sets the LocalNums on the waypoints. Seems to work fine here from what I have tested it. If you want it I could upload it, though it'd require you to recompile the AI scripts for your NPC for it to work, since it's an include file I've modified. I can try it yeah, wouldn't do no harm. And thanks for the help Pavlos, I tried the script but couldn't get it to work. I think I might have missed something. void main() { string sWP = (("wp_" + GetTag(OBJECT_SELF)) + "_0"); int nNumb = 1; object oNPC=GetObjectByTag("astro2"); float fDuration = 40.0; effect eEffect = EffectVisualEffect(4034); object oWP = GetObjectByTag((sWP + IntToString(nNumb)), 0); ClearAllActions(); while (GetIsObjectValid(oWP)) { ActionWait(5.0); ActionMoveToObject(oWP, 0, 1.0); if (nNumb == 3) { ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oNPC, fDuration); } (nNumb++); oWP = GetObjectByTag((sWP + IntToString(nNumb)), 0); } ActionDoCommand(SignalEvent(OBJECT_SELF, EventUserDefined(0))); } I added the above script to the User Defined event of the astro2 npc, the "ApplyEffectToObject" thingy was just a test to show me that the script was working. But no, the npc continues to walk it waypoints in the default manner. :/ Link to comment Share on other sites More sharing options...
Pavlos Posted July 14, 2006 Share Posted July 14, 2006 Rather than applying the effect to oNPC, apply it to "OBJECT_SELF." It is possible that you may have mistyped the tag name. The use of "OBJECT_SELF" also makes it a more universal script. Edit: There may also be an issue with having the duration set at 40 seconds. While it wouldn't normally be an issue, the game can be annoying sometimes and seeing as how you are telling the droid to wait for five seconds and then it is moving off at almost the same time (we're talking miliseconds) as applying the visual effect, it may be being weird. Try to shorten the time and introduce a second "ActionWait()" into the if clause. Link to comment Share on other sites More sharing options...
stoffe Posted July 14, 2006 Share Posted July 14, 2006 I can try it yeah, wouldn't do no harm. Use this version of the k_inc_walkways.nss include file, along with this custom include file, st_inc_utils.nss, to recompile the k_ai_master.nss main AI script. If you are already using a mod that modifies the creature AI, use the relevant include files from that mod instead of the standard game ones to preserve that functionality (aside from the file posted above, of course). Then make a custom OnSpawn script for your NPC, which may look like this (if you already have a custom OnSpawn script, add sections 2 and 3 from this example script to it): #include "k_inc_generic" #include "k_inc_treas_k2" void main() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ST: 1. Standard spawn setup... GN_SetDayNightPresence( AMBIENT_PRESENCE_ALWAYS_PRESENT ); GN_SetListeningPatterns(); SetLocalNumber(OBJECT_SELF, 11, 6); PlaceCritterTreasure(OBJECT_SELF, Random(4)-2); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ST: 2. Custom configuration for waypoint walking. // Enable custom pause delay, and animation usage. GN_SetSpawnInCondition( SW_FLAG_WAYPOINT_PAUSE_CUSTOM ); GN_SetSpawnInCondition( SW_FLAG_USE_WAYPOINT_ANIMATION ); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ST: 3. Add animation and pause delay for relevant waypoints... // 1st parameter: The TAG of the waypoint // 2nd parameter: The animation number or constant, set to 0 to use no animation. // 3rd parameter: The pause duration in seconds. // IMPORTANT: Only 2 decimal numbers supported (i.e. 0.25 and 1.5 are OK, 2.225 is NOT) // IMPORTANT2: The delay will only work if using no animation or looping animations. ST_SetWaypointAnimation("WP_MYTAG_01", ANIMATION_LOOPING_MEDITATE, 6.0); ST_SetWaypointAnimation("WP_MYTAG_02", ANIMATION_LOOPING_WORSHIP, 4.25); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ST: 4. Initialize Waypoint walking. GN_WalkWayPoints(); } The new SpawnIn Conditions in section 2 enables custom pause delay at waypoints, and enables animations at waypoints. Section 3 is where you configure the waypoints you want custom delays and/or animations at. Add one function call for each waypoint. As the comments say, the first parameter to the ST_SetWaypointAnimation() function is the tag of the waypoint (usually "WP_" + the tag of the NPC + "_" + a sequence number). The second parameter is the animation number or constant, like you usually specify as parameter to a PlayAnimation() function. The third parameter is how long the NPC should pause at the waypoint, in seconds. You can only use at most a hundred of a second precision, i.e. 2.5 and 2.25 is okay, while 2.225 is not (2 decimals max). Aside from this setup you shouldn't have to do anything more to make the NPC walk (aside from adding the waypoints of course, if you are making a custom area where the waypoint paths aren't already created. ) (LocalNumbers 20, 21, 22 and 23 are used on the waypoints (not the NPC) to keep track of this data, so if you have scripts that set variables on waypoints in the area, avoid those indexes.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.