I want to make an NPC sit on the ground. Currently I am using the OnHeartbeat script to make this happen.
Here is the relevant code:
____________________________
void main()
{
if(!IsInConversation(OBJECT_SELF))
{
ClearAllActions(TRUE);
PlayCustomAnimation(OBJECT_SELF,"sitgroundidle",1,1.0);
int nAction = GetCurrentAction();
string sAction = IntToString(nAction);
//SpeakString(sAction);
}
}
___________________________
Can anyone think of a better way. I'd rather not have extra code running on HB scripts if possible. The ClearAllActions(TRUE) is in there to make sure the NPC's action cue does not overflow (although I'm not sure PlayCustomAnimation() is an action, so it may be irrelevant.
Efficiently making an NPC sit cross-legged on the ground.
Débuté par
M. Rieder
, mai 30 2011 05:35
#1
Posté 30 mai 2011 - 05:35
#2
Posté 31 mai 2011 - 04:39
AFAIK, PlayCustomAnimation() is an action, but it inserts it into the top of the queue. It shouldn't fill up the queue, though, and anyway ClearAllActions() will probably get called if the NPC ends up in combat or whatever.
#3
Posté 31 mai 2011 - 05:12
Could you just use something like this OnSpawn:
ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 10000.0);
And then for good measure you could redo it in the npc's perception script if it is not currently already doing that action? Or the OnEnter of the area the npc is in, etc..?
ActionPlayAnimation(ANIMATION_LOOPING_SIT_CROSS, 1.0, 10000.0);
And then for good measure you could redo it in the npc's perception script if it is not currently already doing that action? Or the OnEnter of the area the npc is in, etc..?
#4
Posté 31 mai 2011 - 01:26
In several areas where I have a bunch of NPCs doing looping animation I created a on client enter script. It looped through the NPCs in the area and applied looping animation to them. I used PlayCustomAnimation, so if they had a valid local string on them it would apply that animation.
With looping animation you want to set the turn on conversation to false with the script (forget the function name). Other wise sitting NPCs will spin around and make a mess of things.
With looping animation you want to set the turn on conversation to false with the script (forget the function name). Other wise sitting NPCs will spin around and make a mess of things.
#5
Posté 31 mai 2011 - 03:22
@GOG,
I initially tried the OnSpawn event, but I didn't have any success. This has happened to me in the past as well. Not sure what I'm doing wrong, but making animations happen with OnSpawn has never worked for me. It may have something to do with the fact that PlayCustomAnimation() does not go in the action cue like other action functions.
Just FYI, the ANIMATION_LOOPING_SIT_CROSS doesn't work, or at least I have never been able to get it to work. For sitting, I have to use PlayCustomAnimation with the string for sitting ( I think it is "sitgroundidle").
@Shaughn:
Yeah, I have the problem with breakdancing sitting people in my town. I have been meaning to fix that. Thanks for the reminder. I like the idea of using the on enter script better than the heartbeat since it reduces the amount of processes happening.
But I do wonder, how much extra processor power does it use to add a little code into the HB script. Does it really make a difference?
I initially tried the OnSpawn event, but I didn't have any success. This has happened to me in the past as well. Not sure what I'm doing wrong, but making animations happen with OnSpawn has never worked for me. It may have something to do with the fact that PlayCustomAnimation() does not go in the action cue like other action functions.
Just FYI, the ANIMATION_LOOPING_SIT_CROSS doesn't work, or at least I have never been able to get it to work. For sitting, I have to use PlayCustomAnimation with the string for sitting ( I think it is "sitgroundidle").
@Shaughn:
Yeah, I have the problem with breakdancing sitting people in my town. I have been meaning to fix that. Thanks for the reminder. I like the idea of using the on enter script better than the heartbeat since it reduces the amount of processes happening.
But I do wonder, how much extra processor power does it use to add a little code into the HB script. Does it really make a difference?
#6
Posté 31 mai 2011 - 07:28
I have not been able to use the onspawn script to fire looping animation on a place NPC.
I believe it has to do with the reduced ai for inactive areas, (PC is not in them).
I believe it has to do with the reduced ai for inactive areas, (PC is not in them).
#7
Posté 31 mai 2011 - 09:04
To be honest, if you look at the default heartbeat scripts, they are doing a bunch of stuff already anyway. If you put twice as much code in there, you could always just use half as many NPCs (and you're unlikely to be using a processor-heavy number at any time anyway, I wouldn't have thought).
#8
Posté 31 mai 2011 - 10:47
Oops sorry about my suggestion. My NWN2 scripting noobness is showing. I didn't realize the animations for NWN2 were all wonky. I found this sad thread: nwn2forums.bioware.com/forums/viewtopic.html Not sure if it all still applies. But yeah it seems like the HB event is the only way for the animations to work somewhat correctly. Not sure if that was by design or what.
Just another reason to add to the list of why I don't like building/scripting in NWN2 very much.
Just another reason to add to the list of why I don't like building/scripting in NWN2 very much.
#9
Posté 02 juin 2011 - 10:36
If you want your NPCs to always sit in a particular spot, then scripted waypoints may be the go. Or rather, waypoint (singular). If each NPC has it's own tag, then it can have it's own waypoint. If it goes into combat, or runs up to a player via a speak trigger, then it will return to it's waypoint once it's idle again. Then the looping animation can be fired from the waypoint script.
If you set their SetOrientOnDialog flag to FALSE then they shouldn't stand up again if you try to talk to them (unless you want them to stand up of course).
If you set their SetOrientOnDialog flag to FALSE then they shouldn't stand up again if you try to talk to them (unless you want them to stand up of course).





Retour en haut






