Silveredge9 Posted June 24, 2006 Share Posted June 24, 2006 I'm trying to get an NPC to walk specific waypoints, but I can't seem to get it to work. Can anybody point me to a tutorial or some useful threads about NPC waypoints? Link to comment Share on other sites More sharing options...
Lit Ridl Posted July 1, 2006 Share Posted July 1, 2006 May be you need this thread. . Link to comment Share on other sites More sharing options...
Pavlos Posted July 2, 2006 Share Posted July 2, 2006 Hi there, Silveredge9. It is really quite simple (If you just want basic waypoint walking). You'll want to place a series of waypoints, the ResRefs don't matter so don't worry - as long as they are under sixteen characters long . The standard creature template will already have GN_WalkWayPoints() placed in the spawn and user defined fields in their .utc. So provided you just extract and change where necessary, then you should be fine. Anyway, onto your waypoints. In your .git for the module you are editing you will see a field named "Tag." Now set this to wp_MyNPCTag_##. We'll say this is your first waypoint for a creature with the Tag "dro_guard_01." So we will have it as "wp_dro_guard_01_01" (I have found that tags can be over sixteen characters - but my memory could be faulty). The next waypoint the creature walks to will have a tag of "wp_dro_guard_01_02" and so forth. I hope I have gotten my meaning across. That should set you up for having an NPC walking waypoints. You may also wish to create a custom script for the "ScriptEndDialogu" field. This would cause the NPC to resume their walking. Something like this: // k_diae_patrol /* Simple script that stops the creature from just standing there once you have talked to him. He will continue on his waypoint pattern. */ // Created By: Pavlos #include "k_inc_generic" void main() { DelayCommand(2.0, GN_WalkWayPoints()); } If you are unsure whether or not a creature that you have extracted has the necessary scripts - consult the thread Lit Ridl posted. You can create your own script for it. The GN_WalkWayPoints() function essentially runs on: 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); (nNumb++); oWP = GetObjectByTag((sWP + IntToString(nNumb)), 0); } ActionDoCommand(SignalEvent(OBJECT_SELF, EventUserDefined(0))); } You can add in all kinds of things. For example, you could have your creature turn to face a certain point and play an animation at all, or some of the waypoints. Remember that if you are using some sort of custom script - you'll need an individual "ScriptEndDialogu" file. int GetWayPoint() { object oClosest = GetNearestObject(OBJECT_TYPE_WAYPOINT); string sClosest = GetTag(oClosest); int nValue = 1; string sWP = (("wp_" + GetTag(OBJECT_SELF)) + "_0"); while (sClosest != sWP + IntToString(nValue)) (nValue++); return nValue; } void main() { string sWP = (("wp_" + GetTag(OBJECT_SELF)) + "_0"); int nNumb = GetWayPoint(); object oWP = GetObjectByTag((sWP + IntToString(nNumb)), 0); ClearAllActions(); while (GetIsObjectValid(oWP)) { ActionMoveToObject(oWP, 0, 1.0); (nNumb++); oWP = GetObjectByTag((sWP + IntToString(nNumb)), 0); } ActionDoCommand(SignalEvent(OBJECT_SELF, EventUserDefined(0))); } Edit: There will be a stupid error in the above script - the NPC may double back on itself (Not a problem really if you delay the command - it won't look so silly, or if you have a full bread dialogue attached to your NPC). It could be solved through the use of a Local Number. Link to comment Share on other sites More sharing options...
Silveredge9 Posted July 2, 2006 Author Share Posted July 2, 2006 Thanks for the detailed reply, I'm gonna try and implement it laters after I finish this college work. Again thanks, these waypoints have been as annoying as hell. -_- Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.