RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Fix for CanSwim & Monsters going on land

If you are experiencing this condition, where swimming monsters are going on land also, and should not be
(sea serpents, dolphins, etc)
then this is the fix for you

(not sure what all versions had this problem, or which ones it will work with, but should work with all that have the problem)

in engines/pathing/movements.cs file find this section:
Code:
 if ( (flags & ImpassableSurface) == TileFlag.Surface || (canSwim && (flags & TileFlag.Wet) != 0) ) // Surface && !Impassable
{
if ( cantWalk && (flags & TileFlag.Wet) == 0 )
continue;

and replace
if ( cantWalk && (flags & TileFlag.Wet) == 0 )
with
if ( cantWalk && (flags & TileFlag.Wet) != 0 && !canSwim)

and they will work great then

use as you want with it
 

Evanonian

Sorceror
Oh my goodness, thank you so much! I'm gonna try this out right away! I was always having sea creatures on land will this prevent from from spawning on land?

EDIT:

Okay so I tried it and they are still spawning on land. :(

Code:
if ( (flags & ImpassableSurface) == TileFlag.Surface || (canSwim && (flags & TileFlag.Wet) != 0) ) // Surface && !Impassable
{
if ( cantWalk && (flags & TileFlag.Wet) != 0 && !canSwim)
continue;
 
will not stop them from spawning on land, only from moving onto land
you would need to modify the spawner system you are using to check if land or water tiles to place them there or not (probably look to see where it checks for land tiles for normal critters (canswim might be in there for that) and then do a check for cantwalk ones to not spawn on land

i am not doing that my self, i just make sure the spawner is set for the range corectly so they are only able to then spawn in water
(i place it a little ways from the edge of the water and short spawn range)
 

Vorspire

Knight
TileFlags based on TileData file information are not very reliable to say the least, not all tiles have the correct flags - Found this out when I re-wrote BaseBoat for smooth movement, so I decided to re-write the water collision and catalogue every known water tile available (not including swamp, etc, just pure water)

Here's the complete list(s) for both LandTile and StaticTile water tile instances as of client 7.0.24.X

Code:
private static List<int> StaticWaterTiles = new List<int>() { 5465, 6039, 6040, 6041, 6042, 6043, 6044, 13422, 13423, 13424, 13425, 13426, 13427, 13428, 13429, 13430, 13431, 13432, 13433, 13434, 13435, 13436, 13437, 13438, 13439, 13440, 13441, 13442, 13443, 13445, 13456, 13457, 13458, 13459, 13460, 13461, 13462, 13463, 13464, 13465, 13466, 13467, 13468, 13469, 13470, 13471, 13472, 13473, 13474, 13475, 13476, 13477, 13478, 13479, 13480, 13481, 13482, 13483, 13494, 13495, 13496, 13497, 13498, 13499, 13500, 13501, 13502, 13503, 13504, 13505, 13506, 13507, 13508, 13509, 13510, 13511, 13512, 13513, 13514, 13515, 13516, 13517, 13518, 13519, 13520, 13521, 13522, 13523, 13524, 13525, 13597, 13598, 13599, 13600, 13601, 13602, 13603, 13604, 13605, 13606, 13607, 13608, 13609, 13610, 13611, 13612, 13613, 13614, 13615, 13616 };
 
private static List<int> LandWaterTiles = new List<int>() { 168, 169, 170, 171, 310, 311 };

Just a case of checking if either list contains the ID of the tile in question.
I also realise that I could have used an algorithm for adding a range of tile id's to the lists, but I wanted to be able to reference it by sight, too, so stuck with the hard-coded definitions, one by one.

Code:
public static bool IsWater(LandTile tile)
{ return LandWaterTiles.Contains(tile.ID); }
 
public static bool IsWater(StaticTile tile)
{ return StaticWaterTiles.Contains(tile.ID); }
 
Top