Scripted Waypoints: FYI
#1
Posté 30 mai 2011 - 11:46
Here's a link that describes it further:
Link...
If anyone wants to comment about applications of this system, tricks, tips, warnings, known bugs, all comments are welcome.
#2
Posté 31 mai 2011 - 12:47
Comments and such still welcomed here.
#3
Posté 31 mai 2011 - 03:23
#4
Posté 31 mai 2011 - 04:01
If it's not compiling, it might have something to do with the switch/case grammar. Post your script so we can look at it.
#5
Posté 31 mai 2011 - 05:24
#6
Posté 31 mai 2011 - 11:13
Lugaid of the Red Stripes wrote...
I suspect you need to a bit more, like pausing the walkwaypoints and then setting the PlayCustomAnimation on a delay.
If it's not compiling, it might have something to do with the switch/case grammar. Post your script so we can look at it.
Here's the script:
//Plays a custom animation at each waypoint determined by the local string
//sAnimation.
#include "ginc_wp"
#include "x0_i0_walkway"
void main()
{
object oSelf=OBJECT_SELF;
int nWPT = GetCurrentWaypoint();
FaceAndPause(nWPT,0.5f);
PlayCustomAnimation(oSelf,GetLocalString(oSelf,"sAnimation"),1,1.0);
}
Modifié par M. Rieder, 31 mai 2011 - 11:16 .
#7
Posté 31 mai 2011 - 11:17
#8
Posté 31 mai 2011 - 11:27
#9
Posté 01 juin 2011 - 04:02
#10
Posté 02 juin 2011 - 10:47
The most useful feature I've found is the ability to override the NPCs tag so that everyone can run the same waypoint script, simply by setting a local variable on them (WP_TAG). That way you can still target individuals via their unique tags, but you don't need dozens of separate scripts or duplicate waypoint sets.
The down side is that sometimes you find yourself standing about and watching what NPCs will do next, rather than actually playing the module...
#11
Posté 02 juin 2011 - 11:24
#12
Posté 02 juin 2011 - 11:52
DannJ wrote...
I've been playing about with scripted waypoints as well. They're great for randomising NPC walking around towns or merchant stalls, rather than having everyone just walk back and forth along the same path. I also randomise the pause time at each waypoint, just so everyone doesn't up and walk about in synch, like a big game of Musical Chairs.
The most useful feature I've found is the ability to override the NPCs tag so that everyone can run the same waypoint script, simply by setting a local variable on them (WP_TAG). That way you can still target individuals via their unique tags, but you don't need dozens of separate scripts or duplicate waypoint sets.
The down side is that sometimes you find yourself standing about and watching what NPCs will do next, rather than actually playing the module...
That sounds very useful. Could you explain the process of overriding the NPC's tag in more detail?
#13
Posté 02 juin 2011 - 11:53
_Knightmare_ wrote...
I have something similar DannJ. It's very basic right now, but have it set so that all the generic NPCs walk the same WPs. When they get to one of the points, they randomly choose another one and then walk to there. I have the WPs scattered all over the area. Gives a good representation of the general population wandering about.
Do you also do this by overriding the tag? I'd like to keep the tags separate, but I like the idea of everyone using one script. Makes things a lot easier. I'll be puting the ambience in a town in the next few weeks and some new tricks would be nice.
#14
Posté 03 juin 2011 - 12:06
#15
Posté 03 juin 2011 - 09:35
#16
Posté 03 juin 2011 - 10:59
M. Rieder wrote...
_Knightmare_ wrote...
I have something similar DannJ. It's very basic right now, but have it set so that all the generic NPCs walk the same WPs. When they get to one of the points, they randomly choose another one and then walk to there. I have the WPs scattered all over the area. Gives a good representation of the general population wandering about.
Do you also do this by overriding the tag? I'd like to keep the tags separate, but I like the idea of everyone using one script. Makes things a lot easier. I'll be puting the ambience in a town in the next few weeks and some new tricks would be nice.
Yes. Set a local string variable on the NPC that must be named "WP_TAG" without quotes. Set its value equal to the tag of walk waypoints you want them to follow (without the numbers) and they will follow that waypoint set. So if you had 50 people all with that string, you only need one set of walkpoints for all of them, no matter what their individual tags are. Then just have a single script that is run that tells them to go to some random next waypoint:
#include "ginc_wp"
void main()
{
int iCurrentWP = GetCurrentWaypoint();
int iNextWP;
switch (iCurrentWP)
{
case 1:
iNextWP = Random(GetNumWaypoints()-1) + 2;
SetNextWaypoint(iNextWP);
//ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0);
break;
case 2:
iNextWP = Random(GetNumWaypoints()-1) + 2;
SetNextWaypoint(iNextWP);
//ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0);
break;
case 3:
iNextWP = Random(GetNumWaypoints()-1) + 2;
SetNextWaypoint(iNextWP);
//ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0);
break;
///// Etc.
case 19:
iNextWP = Random(GetNumWaypoints()-1) + 2;
SetNextWaypoint(iNextWP);
//ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0);
break;
case 20:
iNextWP = Random(GetNumWaypoints()-1) + 2;
SetNextWaypoint(iNextWP);
//ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0);
break;
}
}
They will just walk randomly from point to point. You can uncomment the animation lines and have them do something once they reach the target WPs location. After doing the animation, they would continue on to the next random WP. The script doesn't get placed on anything, it just needs to exist within the module/campaign and must be named "wp_<tag of walk waypoints>" without quotes.
#17
Posté 03 juin 2011 - 11:06
With ambient animation turned on, the npc's move around from where they are placed, but they do not move very far, maybe a house length, tops. (they also can interact with each other when close, which is nice)The Fred wrote...
Random walking is good. I think they started to use that instead of waypoints from HotU onwards (maybe SoU) - in fact, there are a lot of clever systems still there from HotU which I'm not sure ever got used, and I'm not sure actually work. Look for scripts starting "x2_am_" I think (I'm guessing that stands for "ambient"). There is a bunch of stuff like waypoints you can put down to make people do things and so forth. Mostly I'm just using this for inspiration and making brand new stuff myself, though, but there's probably a veritable mine of untapped resources.
#18
Posté 04 juin 2011 - 12:07
I noticed you used the animation "ANIMATION_LOOPING_SIT_CROSS" in your sample script. Have you been able to make that animation work, or is it just an example. There are quite a few of the animations that I cannot get to work with PlayAnimation or ActionPlayAnimation and have to substitute with PlayCustomAnimation.
I would also like to talk about the ambient animations. Are they pretty simple to turn on? It sounds like a nice shortcut to making a bustling little community.
#19
Posté 04 juin 2011 - 12:23
Yes. it's a variable you set on the npc.M. Rieder wrote...
Are they pretty simple to turn on? It sounds like a nice shortcut to making a bustling little community.
X2_L_SPAWN_USE_AMBIENT == 1 (they move around some)
X2_L_SPAWN_USE_AMBIENT_IMMOBILE == 1 (play some animations, but don't move)
#20
Posté 04 juin 2011 - 06:32
#21
Posté 04 juin 2011 - 06:49
_Knightmare_ wrote...
#include "ginc_wp"
void main()
{
int iCurrentWP = GetCurrentWaypoint();
int iNextWP;
switch (iCurrentWP)
{
case 1:
iNextWP = Random(GetNumWaypoints()-1) + 2;
SetNextWaypoint(iNextWP);
//ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0);
break;
case 2:
iNextWP = Random(GetNumWaypoints()-1) + 2;
SetNextWaypoint(iNextWP);
//ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0);
break;
case 3:
iNextWP = Random(GetNumWaypoints()-1) + 2;
SetNextWaypoint(iNextWP);
//ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0);
break;
///// Etc.
case 19:
iNextWP = Random(GetNumWaypoints()-1) + 2;
SetNextWaypoint(iNextWP);
//ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0);
break;
case 20:
iNextWP = Random(GetNumWaypoints()-1) + 2;
SetNextWaypoint(iNextWP);
//ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 7.0);
break;
}
}
Out of curiosity,_KM_, what is the purpose of your switch-case? All the case instructions seem to be the same.
Modifié par MasterChanger, 04 juin 2011 - 06:50 .
#22
Posté 04 juin 2011 - 06:55
You need one case per waypoint you have.MasterChanger wrote...
Out of curiosity,_KM_, what is the purpose of your switch-case? All the case instructions seem to be the same.
Modifié par kamal_, 04 juin 2011 - 06:56 .
#23
Posté 04 juin 2011 - 07:18
But, I think that KM was just posting an example and I think that KM meant that each case would be the same or different.
#24
Posté 04 juin 2011 - 08:33
M. Rieder wrote...
If the NPC does the same thing at each waypoint, I don't think you need to even worry about what waypoint the NPC is at, just put the lines of code down and they will be executed.
But, I think that KM was just posting an example and I think that KM meant that each case would be the same or different.
Correct, just an example. You need one case statement per waypoint in the set if you want anything special to happen at the waypoint number. So, in my example I have 20 waypoints scattered about the town. As it stands they will just walk between the different waypoints. You can add code under each case and have them do something special when they reach a certain waypoint. For example, if my waypoints were tagged "wp_walkpoint_1" through "wp_walkpoint_20" (my script name as well as the WP_TAG string value would be "wp_walkpoint") and I wanted them to do somethig special when they reached "wp_walkpoint_7" I would add that special/extra code under case 7. As an example of that, maybe WP 7 is outside a door, I could code it so when they reached there, they opened the door and then destroyed themselves, giving the appearance that they entered the building through the door.
Modifié par _Knightmare_, 04 juin 2011 - 08:34 .
#25
Posté 04 juin 2011 - 08:52
switch (iWP)
{
case 1:
case 2:
case 3:
...
case 500: // do something
break;
}Alternatively, if something special happens only at certain waypoints, and the others are generic, you could just leave out your non-special cases, and group all your generic stuff under the default case:
switch (iWP)
{
case 3: // dance like a chicken
break;
case 10: // dance like a drunk chicken
break;
case 20: // critical hit with a vorpal sword! dance like a headless chicken
break;
default: // do something generic and boring like just going to the next WP
break;
}





Retour en haut






