Tinkering with fast travel, question about ocean pixels
Posted: Sat May 04, 2019 10:42 am
Hi,
Some friends and I are working on a mod idea where we add random encounters (including positive ones) to the game to spice up wilderness exploration, resting, and fast travel. We wanted to have a random chance to interrupt fast travel, and we felt it would be a good way to add depth to the cautious / reckless pace and so on (as in, those choices would affect the chance of an encounter occurring, as well as what kind of encounters might occur). But we realized that the fast travel system assumes that you go through the ocean, even if you are not using a ship. As a result, we decided to attempt to modify the fast travel system to avoid bodies of water, and to have a "smart" path that is at least somewhat similar to what a real person would travel along. The algorithm is (theoretically) pretty straightforward -- we make a vector to the desired destination, check if that vector intersects the ocean, and modify the angle of the vector if so. We repeat this process until the vector goes on land instead. It's designed in such a way that the new vector will hug the coastline, for the most part (because the angle increments are small).
However, we've run into a bit of a problem. In order to determine if the vector hits the ocean, we pass in each map pixel along the vector to the MapsFile getClimateIndex function and compare it to the ocean value in the Climates Enum to determine if we are travelling on ocean. For debugging purposes, we also added a check on the ClickHandler function in DaggerfallTravelMapWindow to see if the pixel being clicked is considered ocean. We offset the position by the respective origin stored in offsetLookup, and in many cases the spots that we can visually see as being ocean are correctly identified as ocean when clicked.
But we've noticed, with the ClickHandler debugging, that some of the map pixels that are visually on the ocean are not designated as such*. Understandably, this creates some bugs and unexpected behavior with our algorithm. We were wondering, would it be a simple matter to change the contents of the .pak file ("CLIMATE.PAK") to accurately reflect the extent of the ocean? If so, how might one do this? We don't know how to edit the .pak file, but we figure one could write a program that checks the RGB values of the pixels in each map image and says that it's ocean if it's blue. Then, we could maybe use those pixel locations to overwrite climate.pak with the updated ocean information. But this depends what climate.pak is based on, visually -- for example, is it based on the zoomed out world map?
*We are assuming that the information from the ClickHandler correctly reflects the status of the map pixels.
Additionally, would a functional fast travel pathfinder that avoids ocean be something that is aligned with the goals of the project? It's my understanding that the original Daggerfall also assumed that the player walks on water / swims when calculating travel times across the bay. Immersion-wise, I don't think this makes a lot of sense, but then again, maybe we don't want to mess with the feature in this way. Anyways, we wanted to implement this for our mod, but obviously we've been editing the source code directly, which makes it not a traditional, downloadable mod perse, unless we had some sort of code injection / script extender utility.
Thanks!
Some friends and I are working on a mod idea where we add random encounters (including positive ones) to the game to spice up wilderness exploration, resting, and fast travel. We wanted to have a random chance to interrupt fast travel, and we felt it would be a good way to add depth to the cautious / reckless pace and so on (as in, those choices would affect the chance of an encounter occurring, as well as what kind of encounters might occur). But we realized that the fast travel system assumes that you go through the ocean, even if you are not using a ship. As a result, we decided to attempt to modify the fast travel system to avoid bodies of water, and to have a "smart" path that is at least somewhat similar to what a real person would travel along. The algorithm is (theoretically) pretty straightforward -- we make a vector to the desired destination, check if that vector intersects the ocean, and modify the angle of the vector if so. We repeat this process until the vector goes on land instead. It's designed in such a way that the new vector will hug the coastline, for the most part (because the angle increments are small).
However, we've run into a bit of a problem. In order to determine if the vector hits the ocean, we pass in each map pixel along the vector to the MapsFile getClimateIndex function and compare it to the ocean value in the Climates Enum to determine if we are travelling on ocean. For debugging purposes, we also added a check on the ClickHandler function in DaggerfallTravelMapWindow to see if the pixel being clicked is considered ocean. We offset the position by the respective origin stored in offsetLookup, and in many cases the spots that we can visually see as being ocean are correctly identified as ocean when clicked.
But we've noticed, with the ClickHandler debugging, that some of the map pixels that are visually on the ocean are not designated as such*. Understandably, this creates some bugs and unexpected behavior with our algorithm. We were wondering, would it be a simple matter to change the contents of the .pak file ("CLIMATE.PAK") to accurately reflect the extent of the ocean? If so, how might one do this? We don't know how to edit the .pak file, but we figure one could write a program that checks the RGB values of the pixels in each map image and says that it's ocean if it's blue. Then, we could maybe use those pixel locations to overwrite climate.pak with the updated ocean information. But this depends what climate.pak is based on, visually -- for example, is it based on the zoomed out world map?
*We are assuming that the information from the ClickHandler correctly reflects the status of the map pixels.
Additionally, would a functional fast travel pathfinder that avoids ocean be something that is aligned with the goals of the project? It's my understanding that the original Daggerfall also assumed that the player walks on water / swims when calculating travel times across the bay. Immersion-wise, I don't think this makes a lot of sense, but then again, maybe we don't want to mess with the feature in this way. Anyways, we wanted to implement this for our mod, but obviously we've been editing the source code directly, which makes it not a traditional, downloadable mod perse, unless we had some sort of code injection / script extender utility.
Thanks!