The NPC appears to behave very erratically. It performs actions at the wrong waypoints and skips some waypoints altogether. The debug feedback I put in the script isn't helping. At each waypoint, the current waypoint number is supposed to be returned as well as the tag of the next waypoint. Each time the NPC reaches a waypoint, all the waypoint numbers and strings are displayed.
Here's the script:
#include "ginc_wp"
#include "x0_i0_walkway"
void main()
{
object oSelf=OBJECT_SELF;
object oNextWPT = GetNextWalkWayPoint();
object oSigurd = GetNearestObjectByTag("sigurd_ibsen");
object oHans = GetObjectByTag("hans");
object oFranz = GetObjectByTag("franz");
object oBearl = GetObjectByTag("bearl_albracht");
int nCurrentWPT = GetCurrentWaypoint();
FloatingTextStringOnCreature(IntToString(nCurrentWPT),GetFirstPC());
FloatingTextStringOnCreature(GetTag(GetNextWalkWayPoint()),GetFirstPC());
switch (nCurrentWPT)
{
case 1:
FaceAndPause(nCurrentWPT,7.0);
SpeakString("Anything to report, soldier?");
DelayCommand(2.0,AssignCommand(oSigurd,SpeakString("No, there's never anything to report.")));
DelayCommand(4.0,SpeakString("Very good, carry on then!"));
DelayCommand(5.0,PlayAnimation(ANIMATION_FIREFORGET_SALUTE));
break;
case 2:
FaceAndPause(nCurrentWPT,7.0);
SpeakString("Hans, Franz, is everything alright?");
DelayCommand(2.0,AssignCommand(oHans,SpeakString("Yah, our muscles are growing even bigger!")));
DelayCommand(2.0,AssignCommand(oFranz,SpeakString("Yah, much bigger!")));
DelayCommand(4.0,SpeakString("Very good, carry on then!"));
DelayCommand(5.0,PlayAnimation(ANIMATION_FIREFORGET_SALUTE));
break;
case 4:
FaceAndPause(nCurrentWPT,5.0);
SpeakString("Hmmmm.... well looks fine..... Very good then!");
DelayCommand(3.0,PlayAnimation(ANIMATION_FIREFORGET_SALUTE));
break;
case 7:
FloatingTextStringOnCreature("Don't forget to put a guard in the tower!",GetFirstPC());
FaceAndPause(nCurrentWPT,7.0);
SpeakString("Bearl, is everything clear?");
DelayCommand(2.0,AssignCommand(oBearl,SpeakString("Everything clear sir!")));
DelayCommand(4.0,SpeakString("Very good, carry on then!"));
DelayCommand(5.0,PlayAnimation(ANIMATION_FIREFORGET_SALUTE));
break;
case 12:
FaceAndPause(nCurrentWPT,5.0);
SpeakString("Hmmmm.... warehouse looks fine..... Very good then!");
DelayCommand(3.0,PlayAnimation(ANIMATION_FIREFORGET_SALUTE));
break;
case 13:
FaceAndPause(nCurrentWPT,5.0);
SpeakString("Hmmmm.... everything looks fine here..... Very good then!");
DelayCommand(3.0,PlayAnimation(ANIMATION_FIREFORGET_SALUTE));
break;
case 16:
ActionForceMoveToObject(GetWaypointByTag("WP_bjornstjerne_bjornson_01"));
break;
// default:
}
}
Need some help with this Waypoint script
Débuté par
M. Rieder
, juin 15 2011 10:10
#1
Posté 15 juin 2011 - 10:10
#2
Posté 15 juin 2011 - 10:19
It is baffling. I just saw the NPC go to wpt 13 and do the right thing, then go to wpt 4 and do the action for wpt 13.
#3
Posté 15 juin 2011 - 10:20
GetNextWalkWayPoint() returns the waypoint they are currently en route to. So, if you have wp_1, wp_2 and wp_3, when they are going from wp_1 to wp_2, GetNextWalkWayPoint() should return wp_2 not wp_3. Not sure if that helps any, just thought I'd point it out.
Can you give a more detailed description of what does and what should happen. For example, when they go from your wp_1 (case 1) to wp_2 (case 2) what happens that is wrong?
Can you give a more detailed description of what does and what should happen. For example, when they go from your wp_1 (case 1) to wp_2 (case 2) what happens that is wrong?
#4
Posté 15 juin 2011 - 10:28
The NPC should go to each waypoint in order and at 1,2,4,7,13,14 the NPC should do a barkstring, salute, then move on.
The NPC first of all does not follow the waypoints in order. It seems to bounce between waypoints 5,9,13, and a few others, I can't tell exactly. The other wrong thing is that the NPC will do things at the wrong waypoint. For example. At waypoint 7, the NPC is supposed to ask a guard if everything is okay, but the NPC does this at waypoint 6 and doesn't even go to 7. Also, sometimes the NPC does this at WPT 12.
The NPC first of all does not follow the waypoints in order. It seems to bounce between waypoints 5,9,13, and a few others, I can't tell exactly. The other wrong thing is that the NPC will do things at the wrong waypoint. For example. At waypoint 7, the NPC is supposed to ask a guard if everything is okay, but the NPC does this at waypoint 6 and doesn't even go to 7. Also, sometimes the NPC does this at WPT 12.
#5
Posté 15 juin 2011 - 10:41
I just took the script out for a moment and re-tested the movement. When I get rid of the waypoint script, the NPC walks the waypoints just fine, so there is definietly something wrong with my script.
#6
Posté 16 juin 2011 - 12:03
you are probably calling the script "to fast".
Basically actions are pilled up, and executed one after the other.
You action in case 13 is delayed by 3 sec you action in case 2 can be delayed by 5 sec.
If you call your action 13 before the 2 is finished, then the 3 sec delayed action of case 13 will be executed before the 5 sec delayed action of case 2.
Basically actions are pilled up, and executed one after the other.
You action in case 13 is delayed by 3 sec you action in case 2 can be delayed by 5 sec.
If you call your action 13 before the 2 is finished, then the 3 sec delayed action of case 13 will be executed before the 5 sec delayed action of case 2.
#7
Posté 16 juin 2011 - 03:44
Thanks Shallina, I'll make sure I don't pile functions up in the future.
#8
Posté 16 juin 2011 - 05:42
Actually, KM, I think that OBJECT_SELF does work with scripted waypoints because I have a bunch of scripts that use it in another area that appear to work.
#9
Posté 16 juin 2011 - 06:51
M. Rieder wrote...
Actually, KM, I think that OBJECT_SELF does work with scripted waypoints because I have a bunch of scripts that use it in another area that appear to work.
I just did a simple test by just calling GetName(OBJECT_SELF) and in this case OBJECT_SELF is the NPC! I would have had no idea that's what it was, my bet would have been on the module or the waypoint maybe, but not the NPC walking the waypoints. Learned something new, you got me there.
Modifié par _Knightmare_, 16 juin 2011 - 06:52 .
#10
Posté 16 juin 2011 - 06:53
First time for everything, eh?





Retour en haut






