In response to Naruto 5292
Check out Forum_account's Enemy AI demonstration. It has tons of examples on various ways of handling AI, as well as optimizations.
In response to Naruto 5292
Naruto 5292 wrote:
so can someone just tell me how to do that??I cant figure out how to do it

I'm gonna go a bit meta on you here:

One thing that is always good to remember when taking advice and commentary on this forum. This is primarily a programming forum.

Many of us could answer your question and hand you the code you need, and you could be on your merry way. But we choose to instead invest more of our time in helping you to understand.

Programming is the exercise of pure logic and the understanding of key computer-science concepts. That's all. If we handed you something, sure, you'd get the result of the chain of thought, but would you understand it?

The reason we are often very indirect, and ask a lot of questions around here, rather than giving direct answers, is because it's more helpful to you, to understand WHY you need to do X or Y, and why Z is an inferior option. If we told you why they are good/bad, it wouldn't help you as much as showing you why they are good/bad.

In the end, we want you to be able to think logically about a problem, and solve it in an efficient and thoughtful manner. So, to reiterate the question:

Why would you check if the NPC AI has a key before continuing processing? If it's an NPC, you won't have an associated client, and thus, there's no reason to assume that an NPC should have an associated key value. Think it through.
ya i agree with you.. This will help me to understand like how everyone b4 just handed ,me code and I took it without reconsidering issues. I then solved the problems with that code and understood more. But, this is also something that can help me to understand handing a little bit of code E.G:the view part or distant part.
Best response
I never gave you code only helped you understand what you are doing wrong :)
ya thanks
Hint; it's easier to have the NPC check it's surroundings once activated and deactivate itself instead of having the player do it in some elaborate way
So like get_dist (like get distance/distant) I have a similar code like that for checking distance if the npc should attack or walk away. So should that also be for checking to deactivate them selves?
Heres the code
               for(var/mob/M in oview(7,src))//loops over all mobs within 5 tiles of the monster
if(M.client)//if the mob is human
if(get_dist(src,M) <= 5)//if the player is close
if(src.weaknin||M.NPC)
return

I think that the distant might work
I don't understand why you've posted that string of code here. It doesn't deactivate anything and it's missing its parent code
In response to Dm31st3r
I posted it to see if i could add anything to it to deactivate the npc or get a hint orsomthing
._.
In response to Naruto 5292
First of all, your code is looping through ALL mobs within 7 tiles of src. Then it checks if M has a client, and then later on checks if M is an NPC. What? How does that make even the slightest sense? Last I checked, players were not NPCs.
As i've said before, he should redo his entire var list into seperate lists, specifying which type of mob has what type of var. Makes things like this a million times easier
In response to Dm31st3r
wat
In response to Dm31st3r
This entire thread......
I don't ... do I lock this, do I ... what? I guess I'll lock it, mostly in the hope that OP will put his code into a new, more specific question. Okay?
Page: 1 2 3 4 5