Advertisement

Manageing NPCs out of the screen

Started by September 22, 2003 02:17 AM
14 comments, last by darkbard 21 years, 5 months ago
Hi guys, I posted on Game programming forums asking for a way to manage npcs updateing when they are out of the screen. Someone asked me to use a method that needs to keind of Ai to work. The first AI mange NPCs on the screen, updateing their movement, apparence and so on; the second AI works only for NPCs out of the screen, changeing only basical information in the NPCs-struct. If you want you can read what I wrote here: http://www.gamedev.net/community/forums/topic.asp?topic_id=181591 I''d like to know more information about this tecnique, so I can implement an optimized way to manage npcs out of the screen bye
I think that technique is completely dependent of the game. But you can simplify movement/path-smoothing/A*-checking and Collision Detection for off-screen characters.

if( pChar->Visible() )
{
UpdatePath();
SmoothPath();
CheckCollision();
}
else
{
UpdatePath();
CheckSimpleCollision();
MoveChar();
}

AI Game Programming Wisdom has a nice article about this subject. It describes different Level of detail to use on the ai.

----------------------------------------------
Petter Nordlander

"There are only 10 kinds of people in the world. The who understand binary and those who don''t"
----------------------------------------------Petter Nordlander"There are only 10 kinds of people in the world. They who understand binary and those who do not"
Advertisement
I think I''ll buy the book ... tanks

I''ll post here leater if I find a well-working tecnique.

bye
The kicker is the level of detail. For the most part, if there is something you can''t see, you don''t need to know what it looks like. However, you DO need to know where it is so that you can determine when you will be able to see it again. Also, if the NPCs that are off the screen can respond to things that are happening, you need to be able to still include them in your checks for these actions. For example, if they can respond to something that is happening on the screen... a sound, combat, etc. you will need to have them still check for that so that they can do whatever you tell them to... such as run TOWARDS the view area.

Dave Mark - President and Lead Designer
Intrinsic Algorithm -
"Reducing the world to mathematical equations!"

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Ok, I tried, and it seems to work.

I included also "ability" to here sounds and be allerted and also the "ability" to be hitten by ranged weapons that strike also out of the screen.

I switch to first Ai class when the NPCs enter the screen, and I switch to the second one (that does not manage apparence and other things) when they leave the screen.

It seems to work correctly for my game engine.

I''ve to improve it a lot, because is not fast enaught to manage a lot of NPCs, but it''s OK.

In a multiplayer game, NPCs-status changeing must be managed by the server??
Must the server tell to the clients changes in NPCs status, so, if someone is in the area where and NPC appears, the client can manage correctly what it is doing?

bye






quote:
Original post by darkbard
Ok, I tried, and it seems to work.



Good to hear!

quote:
Original post by darkbard
I included also "ability" to here sounds and be allerted and also the "ability" to be hitten by ranged weapons that strike also out of the screen.



You can think of it like this... there is actually a large world out there with all of the interactions going on that are handled by your game engine. There is also a small part of that world that you have a window into. As InnocuousFox pointed out, you generally need to adjust the level of computational detail based on whether an activity is within your view window of the world or not... and whether, if the event is outside, it is necessary to handle it.

quote:
Original post by darkbard
In a multiplayer game, NPCs-status changeing must be managed by the server??



If you leave it up to the client, it leaves your game open to be hacked by false clients.

quote:
Original post by darkbard
Must the server tell to the clients changes in NPCs status, so, if someone is in the area where and NPC appears, the client can manage correctly what it is doing?



Typically the game client for a Client-Server game handles just three things
1: collection of user inputs
2: transmission of inputs to server and collection of game state from server
3: display of current game state

This minimises the ability for players to hack the game state using a modified client, since all physics and AI is done on the game server.

Cheers,

Timkin
Advertisement
quote:
Original post by Timkin
Typically the game client for a Client-Server game handles just three things
1: collection of user inputs
2: transmission of inputs to server and collection of game state from server
3: display of current game state

This minimises the ability for players to hack the game state using a modified client, since all physics and AI is done on the game server.



it seems obvious
I''l try to implementa small server that "thinks" for the NPCs ... if I''ll have some problem, I''ll ask you ...

bye

Basically, you are taking the NPC processing that you would do in a single player game and putting it into it''s own ''client''. The only change that you would make is how those NPCs communicate with the game world. Even then, since the server is doing the world calcs and the NPCs are on the server, not much would change. Really, in a client/server multiplayer game, the server side IS the stand alone game and you just need to write remote clients.

Dave Mark - President and Lead Designer
Intrinsic Algorithm -
"Reducing the world to mathematical equations!"

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

I planned to create small client programs that manage AI of NPCs that are importants in my World. These programs should be ran when someone is on the net, and thay manage NPCs making them able to create items, build things, and so on.

Do you think it could work?

I''d like to write this small program to do something like SETI: if someone doesn''t want to play the game, he can only run this very small program to improve realism in my World.

I an NPC isn''t controlled by HIS program, it behaves like the NPC on the other MMORPG ... for example: it only sells things, without creating new one, and so on ...





quote:
Original post by darkbard
I planned to create small client programs that manage AI of NPCs that are importants in my World. These programs should be ran when someone is on the net, and thay manage NPCs making them able to create items, build things, and so on.

Do you think it could work?

I''d like to write this small program to do something like SETI: if someone doesn''t want to play the game, he can only run this very small program to improve realism in my World.




You''re asking for a world of torment and heartache here... it would be far too easy for someone to write a hacked AI NPC that destroyed the gameplay experience for your players. You might think that this wouldn''t happen, but trust me, there are people out there whose only happiness comes from the misery of others.

SETI is different in that it works in isolation from the main server, except to update it with the results of its work. It doesn''t need to communicate back to the server in real time and the results don''t affect the data sent out to other clients. Your game, on the other hand, would be different. Your AI clients would perform actions that would affect the game world and thus the data sent to other AI and players. This is very open to corruption.

Timkin

This topic is closed to new replies.

Advertisement