Silveredge9 Posted May 19, 2008 Share Posted May 19, 2008 I'm wondering if it's possible to script an NPC who automatically moves from waypoint to waypoint to perform an action (for examples sake, perform an animation) when they reach a specific waypoint, and then after having performed that action - Move on to the next waypoint. I've seen it done in more then a few places in the actual game. If anybody has any ideas on how this would be done, I'd love to hear them - I can't think of anything. :/ Link to comment Share on other sites More sharing options...
deathdisco Posted May 20, 2008 Share Posted May 20, 2008 It's probably a userdefined or heartbeat script in the *.utc. I would pick apart the module(*.utc's and scripts) where you've observed this behavior for clues. Link to comment Share on other sites More sharing options...
Silveredge9 Posted May 20, 2008 Author Share Posted May 20, 2008 It's probably a userdefined or heartbeat script in the *.utc. I would pick apart the module(*.utc's and scripts) where you've observed this behavior for clues. Yeah, that's usually the first thing I do. I've already determined it's the combination of a custom spawn and user def script. But unfortunately those scripts are only in compiled form, so I can't get a look at how they have done it. I've had an indepth look at walkways.nss, and I think the script I'm looking for is potentially hidden somewhere in there in some form or another - It's just a matter of finding it. :/ Link to comment Share on other sites More sharing options...
Papership Posted May 20, 2008 Share Posted May 20, 2008 The problem with using heartbeats, is that they could potentially stand there for 3 seconds waiting for the next beat. How I would handle this is to place triggers under each waypoint. So your initial script will send the NPC to waypoint 1 for example. And under wp1 is a trigger that when reached, calls a script to animate an action, before then sending the npc on their way to the next waypoint 2, under which will be yet another trigger. So on. It involves more scripts, but this method gives better fluidity. Plus it leaves the heartbeat script field clear for other awesomeness! ~repaP~ (This is assuming NPCs can trigger triggers. I’m not actually sure on this) Link to comment Share on other sites More sharing options...
Silveredge9 Posted May 21, 2008 Author Share Posted May 21, 2008 Right off the top of my head I can think of a method that theoretically should work. It would be a matter of placing a trigger where I would want the NPC to stop and perform an action, adding a script which makes the NPC stop walking waypoints, performs the action, and then carry on walking way points. Although if or not when deactivated and reactivated, the NPC will walk to the first in the number of waypoints remains to be seen. I have a feeling the DEV's used a different, and more practical method in the game itself. Link to comment Share on other sites More sharing options...
glovemaster Posted May 21, 2008 Share Posted May 21, 2008 I recall seeing this in the GN_WalkWayPoints(), I suggest looking at that and modifying it to suit you. This is a function created in the k_inc_walkways.nss file. k_inc_generic.nss includes this, which is turn is included with k_def_spawn01.nss. Link to comment Share on other sites More sharing options...
stoffe Posted May 21, 2008 Share Posted May 21, 2008 I'm wondering if it's possible to script an NPC who automatically moves from waypoint to waypoint to perform an action when they reach a specific waypoint, and then after having performed that action - Move on to the next waypoint. Place a trigger at the waypoint in question and give that trigger an OnEnter event script that checks if it's the correct NPC who's tripping it. If so, clear their action queue, play the animation and then call GN_WalkWayPoints() (include k_inc_generic to call it) to make them resume walking. Something like this as trigger script might work: #include "k_inc_generic" void main() { object oNPC = GetEnteringObject(); if (GetTag(oNPC) == "TagOfNPC") { AssignCommand(oNPC, ClearAllActions()); AssignCommand(oNPC, ActionPlayAnimation(ANIMATION_FIREFORGET_GREETING)); AssignCommand(oNPC, ActionDoCommand(GN_WalkWayPoints())); } } Link to comment Share on other sites More sharing options...
Silveredge9 Posted May 21, 2008 Author Share Posted May 21, 2008 Place a trigger at the waypoint in question and give that trigger an OnEnter event script that checks if it's the correct NPC who's tripping it. If so, clear their action queue, play the animation and then call GN_WalkWayPoints() (include k_inc_generic to call it) to make them resume walking. Something like this as trigger script might work: #include "k_inc_generic" void main() { object oNPC = GetEnteringObject(); if (GetTag(oNPC) == "TagOfNPC") { AssignCommand(oNPC, ClearAllActions()); AssignCommand(oNPC, ActionPlayAnimation(ANIMATION_FIREFORGET_GREETING)); AssignCommand(oNPC, ActionDoCommand(GN_WalkWayPoints())); } } Yeah, It did work. Thanks for the script. As a future reference for anybody else looking at this thread; Below is the onenter script I have used for a trigger positioned near a computer terminal. When the NPC enters the trigger, they walk towards to the computer, turn to face the computer, and type for a bit, then wait a few seconds before continuing to walk from waypoint to waypoint. #include "k_inc_generic" void main() { object oNPC = GetEnteringObject(); vector cPosition=Vector(72.89,78.52,0.00); location lComm3=Location(cPosition,0.0); if (GetTag(oNPC) == "TagOfNPC") { AssignCommand(oNPC, ClearAllActions()); AssignCommand(oNPC, ActionMoveToLocation(lComm3,FALSE)); AssignCommand(oNPC, ActionDoCommand(SetFacing(270.0))); AssignCommand(oNPC, ActionPlayAnimation(ANIMATION_LOOPING_USE_COMPUTER, 1.0, 10.0)); AssignCommand(oNPC, ActionWait(3.0)); AssignCommand(oNPC, ActionDoCommand(GN_WalkWayPoints())); } } Just make sure you remove the mysterious spaces that seem to have appeared between a few words.* * You can dodge that forum-space-injection by using spaces in your code at opportune times like after commas or parentheses). Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.