Ships placed on inland seas

04 Mar 2018 20:12 #37890 by Hevii Guy
Is there an eloquent (simple) way of ensuring that any AI vessel will always sail upon the surface of whichever water it is located?

Currently, AI Ships cannot viably sail on inland waterways because their "altitude" is based on Mean Sea Level. This means that, for example,
  • when placing a model on the Bodensee, it's 'there' but not visible unless one uses the UFO as a submarine and travels 1290' below the surface of the lake!

Defining a unique static altitude for a particular scenario is not a workable solution because:
  • the elevation of navigable rivers is dynamic as one moves downstream
  • the elevation of certain lakes is also dynamic as one moves toward the outflow

I've addressed this dilemma over at the FG forum and had graciously received a bit of code to be placed into the general Nasal directory. It was suggested that the code could be placed within each vessel's xml file. Alas, I've no idea how to do this :unsure: Furthermore, the code does nothing for any vessels other than "carriers" being called by the same scenario.

I'm very grateful to the individuals who had originally helped but now having come across this forum, perhaps its special focus may mean that somebody can provide a better solution. Particularly, since this seems to be an issue which affects anybody who also doesn't want to be limited to running their maritime scenarios on Oceans.

By the way, here's the existing code:
# main() ============================================================

#this needs to match what "name" is designated in the XML
#not the "scenario" name but the "entry" name
var ship = "FGS_Braunshweig";

var main_loop = func {

  foreach(var shipN; props.globals.getNode("/ai/models", 1).getChildren("carrier")) {
    {
      if (string.match(shipN.getNode("name").getValue(), ship")) {

        aiParent = shipN.getNode("name").getParent().getName() ~ "[" ~ shipN.getNode("name").getParent().getIndex() ~ "]";

        var currentLat = props.globals.getNode("/ai/models/" ~ aiParent ~ "/latitude-deg").getValue();
        var currentLon = props.globals.getNode("/ai/models/" ~ aiParent ~ "/longitude-deg").getValue();
        var terrain_elev = geo.elevation(currentLat, currentLon);

        props.globals.getNode("ai/models/" ~ aiParent ~ "/elevation-ft").setDoubleValue(terrain_elev);
      }
   }
  settimer(main_loop, 10);
}

setlistener("/sim/signals/fdm-initialized", func {
  main_loop();
});

Please Log in or Create an account to join the conversation.

05 Mar 2018 14:23 #37892 by enrogue
Hi Hevii

I can see what the code does. When this release is finished (which will have to wait until sourceforge is 100% back online) I'll have a look & see where it needs to be integrated into the code

Please Log in or Create an account to join the conversation.

05 Mar 2018 14:55 #37893 by timi
The oceans have a variable surface level too which makes the ship look like a submarine or a hover craft from time to time. So indeed it would be nice to have the ship follow the surface level...

Please Log in or Create an account to join the conversation.

05 Mar 2018 15:17 #37894 by StuartC
unless it is a submarine............

Please Log in or Create an account to join the conversation.

06 Mar 2018 00:27 - 06 Mar 2018 00:32 #37895 by Hevii Guy

unless it is a submarine............


This hasn't escaped me, Stuart. I had already enjoyed the dark pleasures of submarine warfare as I snuck up below unsuspecting (correctly floating) vessels using the UFO. Even though the "terrain" below water is devoid of any features, it would nonetheless be kinda cool to include AI subs in our scenarios!

Please Log in or Create an account to join the conversation.

06 Mar 2018 00:28 - 06 Mar 2018 00:30 #37896 by Hevii Guy

I can see what the code does. When this release is finished (which will have to wait until sourceforge is 100% back online) I'll have a look & see where it needs to be integrated into the code


Fantastic. Thank-you very much, enrogue!

Please Log in or Create an account to join the conversation.

Time to create page: 0.166 seconds
Powered by Kunena Forum

PM Mailbox

You are not logged in.

Forum Search

Keyword