Aller au contenu

Photo

Basic walkwaypoint scripting help


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I've been having problems with scripted waypoints.  I've read the tutuorial and even generated some good behavior with scripted waypoints, but I'm running into trouble now, even with basic scripts. 

Right now, I'm just trying to debug and make a NPC go between 2 waypoints.  At the first one, a "1" should appear over the PC's head and at the second one, a "2" should appear over the PC's head. 

What actually happens is the NPC gets stuck at either waypoint and just keeps printing the number over the PC's head.


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("worked",GetFirstPC());
//FloatingTextStringOnCreature(IntToString(nCurrentWPT),GetFirstPC());
//FloatingTextStringOnCreature(GetTag(GetNextWalkWayPoint()),GetFirstPC());

switch (nCurrentWPT)
 {
 
 case 1:
 FloatingTextStringOnCreature("1",GetFirstPC());
 DoWalkWayPointStandardActions(oSelf,TRUE);
 break;
  
  
 case 2:
 FloatingTextStringOnCreature("2",GetFirstPC());
 break; 
  
 } 
 
 
  
}  

#2
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
I tried your script above and got the same results you did. Oddly, I then tried the example script that Charles Mead gave, and it was all messed up as well. At WP#1 it was stuck in a continual loop of what was supposed to be happening at WP#2 (an animation in this case). Let me look around in my mod where I have them (seemingly) working and see if I can find the difference...

#3
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
I stripped your test script above down to a working example. The NPC just walks back and forth between the two WPs and at each says "Worked" and the WP number. However, in every test I did, he ALWAYS went to WP#2 first not WP#1. Also, in your script above I think OBJECT_SELF is the module since that is what is running the script.

Stripped down code (just commented out stuff):

#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("worked",GetFirstPC());
//FloatingTextStringOnCreature(IntToString(nCurrentWPT),GetFirstPC());
//FloatingTextStringOnCreature(GetTag(GetNextWalkWayPoint()),GetFirstPC());

switch (nCurrentWPT)
{

case 1 :
FloatingTextStringOnCreature("1",GetFirstPC());
//DoWalkWayPointStandardActions(oSelf,TRUE);
break;


case 2 :
FloatingTextStringOnCreature("2",GetFirstPC());
break;

}

}

#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Thanks for your help KM. I'm going to start over and add stuff bit by bit to see where the problem starts.

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I'm really not sure exactly what I was doing wrong before, The OBJECT_SELF thing probably didn't help, but it seems like it is starting to work properly. Thanks for helping me work through this.

#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I think I found out what broke it. As soon as I added the funtion PlayAnimation(), it stopped working. I think that is what broke it....

Yep, just put in PlayCustomAnimation() and it worked a treat!

#7
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
NP, glad to hear things are working. :)

#8
Morbane

Morbane
  • Members
  • 1 883 messages
Just wondering... but you didnt have PlayAnimation() in your script above.

Edit: That must be from the other post nvm.

Modifié par Morbane, 16 juin 2011 - 09:43 .