Announcement

Collapse
No announcement yet.

Does anybody know how the GetNearestWater function work?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Ahh, now I remember:

    Code:
    int_f CTC_IsSeaTerrain(location_t theLoc){
    
        location_t tmpLoc;
        tmpLoc=theLoc;
        if ((9 < TerrainType(tmpLoc) && TerrainType(tmpLoc) < 17) 
    || TerrainType(tmpLoc)==22 || TerrainType(tmpLoc) ==23 ){
             return 1;
        }
        return 0;
    
    }

    Comment


    • #17
      Originally posted by J Bytheway
      Yep, there was, and it was called TerrainType. e.g. I used
      Code:
      if (TerrainType(city.location) == 13)
      to test for space cities. I doubt that you could have missed that if it still existed, though.
      Well here is my MG_IsLand function:

      Code:
      int_f MG_IsLand(location_t theLoc){
      location_t MGLoc;
      MGLoc = theloc;
      	return((TerrainType(MGLoc)<=9)
      	||((TerrainType(MGLoc)>=18)
      	&& (TerrainType(MGLoc)<=21))
      	);
      }
      As you can see I use the TerrainType as well. But that was not that I was looking for. For instance if I change the order of the terrains in the terrain.txt this function above wouldn't work.

      Originally posted by J Bytheway
      There was also an IsUnderseaCity(city) function, which might be useful if it still exists, and an IsSpaceCity - but that one didn't work - hence the above workaround.
      There is also a IsUnderSeaCity function and I think also a IsSpaceCity function. Well I haven't tested it. But I doubt that the IsUnderSeaCity function works, because whenever undersea tunnels are under a city the terrain is considered as land tile and therefore also the undersea cities, that's the cause of the sea city sprite bug. Well in that case even a build in IsLand function wouldn't work.

      -Martin
      Civ2 military advisor: "No complaints, Sir!"

      Comment


      • #18
        Hmm... I see the problem.

        Perhaps you should try GetNearestWater on a sea city tile and see whether it returns 1 or 0 - If it is being treated as land as you say then it might return 1 and then you can indeed test whether there is any water on the map by using GetNearestWater on the capital city.

        Comment


        • #19
          You can in place of numbers use the DB-references in that function:
          Code:
          if(TerrainType(tmpLoc) == TerrainDB(TERRAIN_PLAINS)){
          For instance. Although in fact the converse would be better, checking it's not a sea terrain rather than is a land terrain, because land terrains are more likely to be added as dummys in scenarios, and AFAIK nobody has ever published anything with an added sea terrain.
          Concrete, Abstract, or Squoingy?
          "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

          Comment


          • #20
            Looks like GetNearestWater scans the whole map for water tiles and returns finally the shortest distance.

            -Martin
            Civ2 military advisor: "No complaints, Sir!"

            Comment

            Working...
            X