scripting woes

Post » Tue Dec 29, 2009 1:43 pm

my latest iteration gets the NPC to properly escort to the first coordinates, then he goes back to standing in place and running state up every frame.

i'm thinking of placing invisible activators at the waypoints that are scripted to do the change in state with a getdistance check. if i attach a script to such an activator that had a script like this on it -

short tempstateset tempstate to RAK_ilmm_patrol_leader.stateif ( getdistance, "RAK_NPCNAMEHERE" <= 25 )        set RAK_ilmm_patrol_leader.state to ( tempstate + 1 )        disable        returnendif


that would basically work around the getaipackagedone wonkyness and make the NPC start moving to the next set of coordinates, right? if i cant remotely change the variable in patrol_leader like that (i forget the exact rules right now, dont have MWSFD open in front of me at the moment) i'll just transfer the information in a global.
User avatar
Nadia Nad
 
Posts: 3391
Joined: Thu Aug 31, 2006 3:17 pm

Post » Tue Dec 29, 2009 5:56 pm

i tried emulating the method used in traveling merchants, putting the getaipackagedone check into a separate state following the escort state. this again gets the NPC to the first waypoint, then shoots through all remaining states without executing the escort functions. relevant section is -
	if ( state == 0 )		if ( doonce == 0 )			aiescort, "player", 0, -6807, -18369, 973, 0			set doonce to 1			set state to 1			return		endif	elseif ( state == 1 )		if ( getaipackagedone == 1 )			set doonce to 0			set state to 2		endif


again it seems that getaipackagedone is returning true forever. i seriously doubt the problem is that the NPC cannot find a path to the waypoint because from start to wp1 is longer and has more obstacles than wp1 to wp2. the NPC also bumped into a wall a the gate of moonmoth, then successfully navigated around it.
User avatar
Ice Fire
 
Posts: 3394
Joined: Fri Nov 16, 2007 3:27 am

Post » Tue Dec 29, 2009 8:59 am

tried in two new ways. first i tried invisible activators as waypoints, if they are within a certain distance of the player, they set the state to state + 1. that didnt work, so i decided to skip trying to directly change the variable remotely, and transferred the information with a global. now, when the player (or NPC, i checked both) is within 25 GU from the invisible activator, it sets a global variable to 1. in the NPC's script, when that variable is 1, it sets state to state + 1.

what happens is the NPC walks to the first coordinates in the list (corresponding to state = 0), then starts trying to walk back some. he then walks that little loop forever, with state == o.

manually flipping state to 1, or the new global has no effect. it almost seems as if the script has stopped processing.

could this be a side effect of not having a pathgrid? i do not think the waypoints are too far apart, from 0 to 1 is a longer distance than from 1 to 2. state should flip to 1 regardless.

so any ideas on what i'm doing wrong?
User avatar
Ron
 
Posts: 3408
Joined: Tue Jan 16, 2007 4:34 am

Post » Tue Dec 29, 2009 5:34 pm

You seem confident that the next waypoint is accessible, but if it were me... I would want to know for certain that was the case before devising new workarounds. Create a new waypoint a few hundred units from the first and test any of your current scripts to see if the NPC will travel there from the first waypoint. If not you will know it is the fault of your code, but if the NPC does reach it then it makes a pretty strong case that the code will work if you make the journey in shorter stages. As for pathgrids I find them a mixed blessing for AITravel/AIEscort. They may improve the NPC's navigation, but it tends to wrestle away control of the NPC from your script. They can be helpful in some situations, but they are not necessary.

I am away from the boards for several days hereafter so you are on you own.
User avatar
Joe Alvarado
 
Posts: 3467
Joined: Sat Nov 24, 2007 11:13 pm

Previous

Return to III - Morrowind