Jump to content
  • 0

ZSCRIPT AI. NPC that wanders around and stops occasionally.


Cacodoomonic

Question

I'm having a serious problem trying to get this to work. I'm trying to create an AI script using ZSCRIPT for an NPC that wanders around randomly but occasionally STOPS moving and mumbles to himself before continuing wandering around aimlessly. For some reason, I cannot make this work. Usually, the character just stays completely still until they mumble to themselves and move only when they do. (basically the complete opposite of what I'm trying to do. Can anyone help? My code is as follows:

 

//wandering variant for natural habitats
class MiseryGuts : Actor
{
	Default
	{
		Speed 10;
		Radius 30;
		Height 56;
		Mass 400;
		Renderstyle "Normal";
		Bloodcolor "none";
		SeeSound "npc/mumble";
        ActiveSound "npc/mumble";
		}
	States
	{
	Spawn:
        CHAT ABC 8 {A_Wander(); A_StartSound ("npc/mumble");}
		MUMB AAAAAAAAAAAAA 8; 
		MUMB AAAA 0 A_LookEx (LOF_NOSOUNDCHECK, 32, 0, 0, 30, "See");
		MUMB AAAAAAAAAAAAA 8; 
		CHAT ABC 8 {A_Wander(); A_StartSound ("npc/mumble");}
		MUMB AAAAAAAAAAAAA 8; 
		CHAT ABC 0 A_LookEx (LOF_NOSOUNDCHECK, 32, 0, 0, 30, "See");
		loop;
	See:
	    CHAT A 8 {A_LookEx(); A_StartSound ("npc/mumble");}
		CHAT B 8 A_Look; 
		CHAT C 8 A_Look; 
		MUMB BCDEBCDEBCDEBCDEBCDEBCDE 8 A_Wander;
		MUMB A 0 A_LookEx (LOF_NOSOUNDCHECK, 32, 0, 0, 30, "See");
		MUMB BCDEBCDEBCDEBCDEBCDEBCDE 8 A_Wander;
		CHAT A 8 {A_LookEx(); A_StartSound ("npc/mumble");}
		CHAT B 8 A_Look; 
		CHAT C 8 A_Look; 
		MUMB BCDEBCDEBCDEBCDEBCDEBCDE 8 A_Wander;
		MUMB A 0 A_LookEx (LOF_NOSOUNDCHECK, 32, 0, 0, 30, "See");
		Loop;
	}
}

The game also closes down randomly (as if this script is causing a crash). Help please?

Edited by Cacodoomonic

Share this post


Link to post

7 answers to this question

Recommended Posts

  • 0

The A_StartSound does the mumble, and A_Wander does the movement. If you dont want the NPC to do it both same time, do not put it in the same frame.

 

Do not call A_Look or A_LookEx in See states. That is what causes the crash.

Share this post


Link to post
  • 0
22 minutes ago, jaeden said:

The A_StartSound does the mumble, and A_Wander does the movement. If you dont want the NPC to do it both same time, do not put it in the same frame.

 

Do not call A_Look or A_LookEx in See states. That is what causes the crash.

Ahhhh thank you. How would I make the NPC stop wandering in order to mumble? I was using A_LOOK thinking that would at least stop them. But it causes the crash. So how do I stop them wandering to play their speech clip before continuing the wandering?

Share this post


Link to post
  • 0

A_Wander basically does just one step. Whenever the NPC is in frame without A_Wander, it does not move.

Share this post


Link to post
  • 0

Perfect, thank you so much. Works great now. :)

 

EDIT: Just noticed a big problem. I had to mark the NPC as "monster" in its code so it knows to spawn a shadow. But now, if you fire a gun around them, they run around constantly and mumble over and over. Is there a fix for this?

Edited by Cacodoomonic

Share this post


Link to post
  • 0
2 hours ago, Cacodoomonic said:

Perfect, thank you so much. Works great now. :)

 

EDIT: Just noticed a big problem. I had to mark the NPC as "monster" in its code so it knows to spawn a shadow. But now, if you fire a gun around them, they run around constantly and mumble over and over. Is there a fix for this?

 

You could try giving the actor the flag:

+CASTSPRITESHADOW

 

And remove the monster attribute.

Edited by Wo0p

Share this post


Link to post
  • 0
11 minutes ago, Wo0p said:

 

You could try giving the actor the flag:

+CASTSPRITESHADOW

 

And remove the monster attribute.

Oh fantastic. This must be a new feature? I never saw this one before. Thanks! All working great now.

Share this post


Link to post
  • 0
Just now, Cacodoomonic said:

Oh fantastic. This must be a new feature? I never saw this one before. Thanks! All working great now.

 

You're welcome :) glad it helped!

 

Hm "new" from GZDoom 4.6.0 I believe? But don't hold me to that I'm not big on keeping up with news, "real" world or not x)

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...