Marked, on 01 August 2011 - 04:30 PM, said:
I added a few enemies to my map today and noticed they don't want to cross over water. Is that a coding thing with an option I can set to bypass? I have a sprite bridge built over the water and they will not cross. Its too easy to kill them if they just stand around at the edge. This is my first attempt of placing enemies in a map and I guess I'll have to do some reading to figure stuff out on my own, but just another quick question to get me started. How do I get an enemy to stay within it's starting sector until the player passes nearby?
If your map is going to be a town map with town type quests, shops etc., which is what I imagined, then we probably shouldn't be worried about placing enemies in it yet.
But since you asked, here is the situation regarding water. In most maps, it is bad news when an enemy enters a water sector. Due to hardcoded facts about water sectors, it is very difficult for them to get out. If there is an under water sector connected to the lotag 1 sector, the enemies will sink into that and never get out. That's why in Duke 3D there are maps where pigcops and other enemies walk into the water and end up in some underwater area for the rest of the game (and not drowning). Even if there is no under water area (i.e. it is just a lotag 1 sector with no SE 7) enemies still tend to get stuck in it. They walk around hip deep, sometimes standing on top of the water, and usually cannot get back on land.
For these reasons, I added code that prevents non-flying enemies from entering lotag 1 sectors. Making an exception for sprite bridges is not as simple as it sounds. Being able to detect whether there is a sprite bridges is pretty difficult, let alone making sure that the enemy stays on the bridge when crossing. Also, enemies tend to fall through sprite bridges, especially if they are jumping enemies.
I could bust my ass coming up with a system that made enemies smart enough to cross sprite bridges over water, but it's not worth the effort. It would be far easier, and no less fun for the player, to simply avoid the necessity for that situation. For example, any flying enemy (such as a wyvern or wraith) will fly over the water without hesitation.