Jump to content

Monster AI does the alert noise too many times.


lxFirebal69xl
 Share

Recommended Posts

Exactly as it says on the tin, I've been getting the AI ready for my game when this started happening, basically when the monster atackes you, he does the alert noise again when you run away from him, doesn't matter if it hits you or not, he keeps spamming the alert noise over and over again, is there any way to make it so that it only does the alert noise once?

Link to comment
Share on other sites

Where the code for the noise is

 

if self.alertnoise == false then

playsound code etc

self.alertnoise = true

end

 

Problem is, I don't know where exactly to put this code, I think it's here or around here. I'm not sure though...

if self.entity:Follow(self.target.entity,self.speed,self.maxaccel) then
   if prevmode~="chase" then
 if self.sound.alert then self.entity:EmitSound(self.sound.alert) end
   end

Link to comment
Share on other sites

To use self.alertnoise you would have to put at the top of your script

 

Script.alertnoise = false

 

if self.entity:Follow(self.target.entity,self.speed,self.maxaccel) then
if prevmode~="chase" then
if self.sound.alert then
if self.alertnoise == false then
self.entity:EmitSound(self.sound.alert)
self.alertnoise = true
end
end
end
end

 

 

The above is quite crude but should do the job.

 

You will also need to set the alertnoise to true again at some point.

 

It will be worth going through the tutorials on Lua, the basics can be picked up quite quick.

Elite Cobra Squad

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...