ID:177880
Jul 20 2002, 8:02 am (Edited on Jul 20 2002, 8:20 am)
|
|
I'm still looking fo a code to keep monster on one kind of turf or keep them within certain boundaries. oh yeah and how do I make it so when you kill a monster you get money for it?
|
In response to Lummox JR
|
|
thanks I tested it and it works!
|
In response to Codesterz
|
|
Codesterz wrote:
thanks I tested it and it works! Cool. If you elaborate on that code further in the future, I'd love to see what else you come up with. The options for limiting or directing monster movement are quite varied, and you might find that some of the choices you make may even add to the apparent intelligence of the monsters. Once you begin setting down rules and patterns for how a creature can move around, they begin to seem a lot more alive. Lummox JR |
Just FYI, "a code" doesn't make any sense. When you're referring to programming, "code" is plural.
There are a few ways to do what you want. One is to assign the turf to a particular area, and use Exit() to check if the monster can leave:
Another way is to alter the Move() proc for monsters:
You can also get fancier than that. Say you have a monster constricted to a certain area, say within 5 spaces of var/atom/home:
Notice the ifs in there. The first one allows the monster to move to null without a problem. The next check will reset the home atom (i.e., "leash" the monster to a new spot) to wherever they step next, IF:
The home turf is only set if the movement is completed, which is the reason for calling ..() first and checking its return value.
If home turf doesn't move, then the monster checks to see if its new location is in range. If it is, then movement proceeds without a hitch. If it isn't, it returns 0 to indicate movement failed.
Lummox JR