Ticket #42077

Changed behaviour of extra resources placed as hut

Date d'ouverture: 2021-04-26 20:46 Dernière mise à jour: 2021-11-10 10:11

Rapporteur:
(Anonyme)
Propriétaire:
Type:
État:
Atteints
Composant:
Jalon:
(Aucun)
Priorité:
5 - moyen
Sévérité:
5 - moyen
Résolution:
Invalid
Fichier:
Aucun

Détails

In the current version of my ruleset civ2civ3_earth (available with Modpack Installer for freeciv v2.6) there is a problem with strategic resources, they disappear from the map while game progresses.

I implemented strategic resources as terrain extras with the line: causes = "Hut". In my recent tests with v2.6.4 these extra resources are randomly placed in the map as I expected, but they disappear as soon as a unit enters the tile (same as standard huts).

When I tested it, before the open release of v2.6, these strategic resources remained in the map for the entire game, and units did not make them disappear (my desired behaviour). I played several games along a year using S2_6, and I'm almost sure the behaviour has changed since then (while the ruleset code have not changed in 2 years).

I'm guessing it is due to some change to hut code, but the related tickets I have found are planed for 3.1: Ticket #41610, https://www.hostedredmine.com/issues/923073. I have not found the ticket that might have changed it for v2.6.

Can you help me fix my ruleset to get the old behaviour again: an extra that is randomly placed on the map by the generator, without overlapping with other special resources, and not removed by units or by any other cause? Or to help me find the related ticket?

[extra_uranium]
This is the current code:
name           = _("Uranium")
category       = "Natural"
causes         = "Hut"
;rmcauses       = ""
graphic        = "tx.uranium"
graphic_alt    = "tx.village"
activity_gfx   = "None"
act_gfx_alt    = "-"
act_gfx_alt2   = "-"
rmact_gfx      = "None"
rmact_gfx_alt  = "-"
reqs  =
    { "type", "name", "range", "present"
      "TerrainFlag", "Uranium", "Local", TRUE
      "Resource", "Iron", "Local", FALSE
      "Resource", "Gold", "Local", FALSE
    }
buildable      = FALSE
removal_time   = 0
helptext       = _("\
Strategic resource, required in a city to build the wonder Manhattan \
Project. Cities with available Uranium build Armor and Submarine \
units with one extra veteran level. Uranium also doubles the bonus \
of Nuclear Plants to the production of the city./
")

The whole ruleset is based on these extra resources and right now it is practically broken.

Ticket History (3/8 Histories)

2021-04-26 20:46 Updated by: None
  • New Ticket "Changed behaviour of extra resources placed as hut" created
2021-04-26 21:01 Updated by: cazfi
Commentaire

In 2.6, it's a hardcoded behavior that "Hut" extras are removed when unit enters them. Later versions (don't remember if it's in 3.0 already) make it ruleset controllable by introducing rmcause "Enter". IIRC there was a bug during S2_6 development that sometimes made hut extras not to disappear when they should (or arguably a feature, but in that case; an inconsistent design that was dropped)

2021-04-26 21:11 Updated by: cazfi
Commentaire

Can you implement them as Resources? Those too are placed by the generator.

The other alternative (in S2_6) is to place them in the lua script, on map_generated signal (along map labels).

2021-04-26 21:57 Updated by: bard
Commentaire

Ah, that explains it. I admit I took advantage of this "inconsistent" behaviour, and I remember I did not expect it to work as it did. I understand you dropped it.

At the time I also created and tested a lua script, but (iirc) the problem was that they could be placed over other resources (in the same tile), and I did not find a way to avoid it.

-- Add random extra resources to the map.
function place_extra_resources(turn, year)

  if turn == 1 then
    for place in whole_map_iterate() do
      local terr = place.terrain
      local tname = terr:rule_name()

      if random(1, 100) <= 2 then
        if tname == "Desert" then
          place:create_extra("Niter")
        elseif tname == "Plains" then
          place:create_extra("Niter")
        elseif tname == "Swamp" then
          place:create_extra("Rubber")
        elseif tname == "Jungle" then
          place:create_extra("Rubber")
        elseif tname == "Forest" then
          place:create_extra("Rubber")
        elseif tname == "Tundra" then
          place:create_extra("Aluminum")
        elseif tname == "Hills" then
          place:create_extra("Aluminum")
        elseif tname == "Glacier" then
          place:create_extra("Uranium")
        elseif tname == "Mountains" then
          place:create_extra("Uranium")
        end
      end
    end
  end
end

I'm not sure why I did not implement them as standard resources, but I think to remember it was related to the chances of appearance being different depending on the number of different resources available in a certain terrain.

Could it be possible to affect the probabilities by including several times the same resource, something like this:

[terrain_plains]
name                 = _("Plains")
...
resources            = "Wheat", "Wheat", "Buffalo", "Buffalo", "Horses", "Horses", "Niter"

[terrain_tundra]
name                 = _("Tundra")
...
resources            = "Game", "Game", "Game", "Furs", "Furs", "Furs", "Aluminum"

Would it be 1/7 in both cases for Niter and Aluminum?

However, I guess changing them to resources would break compatibility with current savegames, and then break it again if they can work as extras in 3.0 (I've to test it yet). I suppose I'll use the lua script for v2.6.

2021-04-26 22:04 Updated by: cazfi
Commentaire

Reply To bard

if they can work as extras in 3.0

Plot twist: Resources are extras in 3.0.

2021-05-10 03:28 Updated by: bard
Commentaire

I tested to use standard resources, but my strategic resources do not give any bonus until the discovery of certain tech, and they would spoil the uniform distribution of the rest of special resources. Also, that way does not allow to adjust the chances of appearance independently, like the extra hut method.

At the end I used the LUA script as solution, but I think it is kind of a bug that the script might place the strategic resources (extras) in the same tile than other special resources, even when the ruleset specifically disallow it.

I mean, the script command place:create_extra() places the extra even if it is illegal in this ruleset (and there is no way to check if it is a valid tile for the extra, that I know). If I open the game editor, it is not possible to place the extra in tiles where the LUA script do place them. Although it might be considered a feature, I don't know.

Anyway, I'd like to ask if you can update the modpack server with the new fixed version of my civ2civ3_earth ruleset. I uploaded it to: https://github.com/dftec-es/civ2civ3_earth/tree/v2018_10b/2.6

Should I open a new ticket for this request? Thanks. Opened new ticket here: #42429

(Edited, 2021-05-31 07:41 Updated by: bard)
2021-06-01 22:37 Updated by: bard
Commentaire

I want to confirm that this issue is not a problem in v3.0.

The new resource system is very versatile and well implemented, congratulations to the developer. In terrain.ruleset I used:

appearance_reqs      =
    { "type", "name", "range", "present"
      "MinYear", "1", "World", FALSE
    }
It works the same as my LUA script from 2.6: random placement with configurable probabilities that do not affect the distribution of the other resources, but this new method allows to avoid that they are placed in the same tiles than other resources. I have also seen that 3.0 LUA functions allow to check if there are other resources in the tile (before placing a new one), so I guess this ticket can be closed, unless there is some plan to try a fix/workaround for 2.6.

2021-11-10 10:11 Updated by: cazfi
  • État Update from Ouvert to Atteints
  • Propriétaire Update from (Aucun) to cazfi
  • Résolution Update from Aucun to Invalid
Commentaire

Reply To bard

I guess this ticket can be closed, unless there is some plan to try a fix/workaround for 2.6.

2.6 is almost EOL, so closing this.

Attachment File List

No attachments

Modifier

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Connexion