I have an AI system setup for my mob, but I dont want the mob to walk all over the world. I want the mob to stay in an area i set up. How can i set it up so that the mob can walk randomly in an area without going out of bounds?
Example:
10
9
8 ________
7 |...........|
6 |.....M....|
5 |.M........|
4 |...........|
3
2
1
1 2 3 4 5 6 7 8 9 10
10 x 10 is the world, the square box is the area I want the mob to move randomly in, M is the mob. Please help me get started on this code. Thanks in advance.
ID:166700
![]() Jun 28 2006, 9:04 am
|
|
![]() Jun 28 2006, 10:50 am
|
|
Add a monstor block o.o
|
Without testing this, I couldn't be sure if it would work but you could create a literal Area for him and have it deny exit when he tries to wander out.
area/Mob_Wander Hell, you could even define a list of mob types for each area so you don't have to hardcode it each time. |
I'm not sure what you mean when you say the word 'area'. Do you mean the atomic object /area? Or do you mean area in the general sense, like region? From the content of your post I'm guessing you mean the later. Keeping an /atom/movable (like a mob or obj) from leaving a region can be done with /area objects by returning FALSE when they ask to exit the area:
area Or, we could modify the /atom/movable's movment proc so as to keep it in the region: region Personally, I prefer the second method, as it leaves /area objects open for better uses. |
this is an interesing problem as I will eventually attack the same type of problem, my npc must stay in their respective areas but the other types of mobs may pass.
ie the banker stays in his bank, the toyshop keeper stays in the toyshop, but other mobs and npcs may go anywhere they like. |
IainPeregrine wrote:
> monster I keep getting an error that is_contained is a undefined proc. on the line "if(region.is_contained(new_loc))" I've tryed (region/is_contained(new_loc)) and (region/is_contained()) if you have any ideas please let me know. Thanks |
To be honest, that whole region object was a very poor choice on my part. It would have been easier to save a central turf and check if the new location was in range(center_turf, radius).
monster |