Using Natural Wonder graphics for features

PawelS

Ancient Druid
Joined
Dec 11, 2003
Messages
2,811
Location
Poland
I have problems with using the Natural Wonder graphics for features in my mod.

For testing purposes, I have changed the ArtDefineTag for FEATURE_OASIS to ART_DEF_FEATURE_VOLCANO, and I got only the fire and smoke effect. For the other ones, like ART_DEF_FEATURE_FUJI and ART_DEF_FEATURE_CRATER, I got nothing (but they are visible in the Strategic View). Does anyone have any advice how to make it work properly?

I have checked "reload landmark system" in the mod properties.
 
Just a guess, but perhaps your problem is related to Landmark art "states". This is what it stopping me from using wonder art as improvement. IIRC, state=1 is the final finished state for improvement art, but state=1 is the "under construction" state for wonder art. So when I use wonder art as improvement they are stuck forever at the under construction graphic. (You can reprogram what states run what animations in the fsxxml file, but not how states interact with the gr2 file.) Natural Wonders are really improvements, so you might have an analogous problem here.

I suspect that this all may be tied to the Events system, since it is purely a graphic issue. For example, Events.SerialEventImprovementCreated and similar events probably fire as the improvement changes state (with state=0 for unseen). There are a variety of mysterious Events that have "state" in their name (e.g., StateMachineDumpStates, StateMachineRequestStates), but I don't see any that seem likely to give us Lua control over states.

What we really need is some understanding of gr2 files so that Natural Wonders could be "rebuilt" as a feature (i.e., the right graphic is shown based on feature state rather than improvement state), Wonders could be rebuilt as improvements, etc.
I have checked "reload landmark system" in the mod properties.
Before someone comments by saying this will crash your game, let me just say that there is no clear evidence either way on that. This was noticed very early before many major patches that did many (undocumented) things to graphics processing. I have not seen any such crashes but my mod never reaches a state of many units / many map improvements that may be required to trigger the problem.
 
Features also have ContinentArtType, while improvements don't. Well...perhaps this is an integer and acts like wonder or improvement states? So maybe you need state=2 for the Natural Wonder graphic to show but the feature is stuck at state=1 because you happen to be in Africa? (I'm just making up numbers here.) If so, you might be able to trigger the right integer by screwing around with plot:SetContinentArtType(). This is all a lot of guesses, of course.

Edit: there is also a plot:ResetFeatureModel(). Not sure what this does but I'd try it anyway.
 
I suspect that this all may be tied to the Events system, since it is purely a graphic issue. For example, Events.SerialEventImprovementCreated and similar events probably fire as the improvement changes state (with state=0 for unseen).

Correct. If you observe an improvement being created, the SerialEventImprovementCreated event will trigger twice; once from the transition to the under-construction state (0 -> 1), and then again when it transitions to the fully constructed state (1 -> 2). However, if the improvement is being created in an area where you don't have visibility, then when you move your unit to a point where it can see the completed improvement, it'll trigger that event once (0 -> 2), even if the improvement was actually built a hundred turns earlier.

You see, when I first started adding Terraforming code to my own logic, I'd used that event to control it. You'd build a "BUILD_FOREST" improvement, and when its construction completed the improvement would be replaced with a forest through a Lua event. But unfortunately, this Event is limited in the ways I described; an AI player would have to wait until the human looked at his area to get the actual benefits of the Forest, and the event's double-firing for the player's lands would cause headaches. And then, the fact that large numbers of improvements would need graphical updating would cause crashes when a high-mobility, high-visibility unit (like a Caravel) would pass nearby, which leads to...

Before someone comments by saying this will crash your game, let me just say that there is no clear evidence either way on that.

Yeah, it most certainly DID crash your game. Maybe you've never run into this personally in your own mods, and maybe they've improved it since the olden days, but there was no question that this flag was responsible for a ridiculous number of crashes in my own mod, or any other mod that spent most of its time in a fully developed world. It was especially common in mods that had units with really high movement rates or large visibilities, to where a single movement command might require a few dozen hexes to update their graphics at once; part of this is that the game does not cleanly separate the execution of events, and won't wait for one update to finish before beginning the next. (You can see a similar effect in the RunCombatSim event, where the next combat's animation can begin before the previous one finishes.)
It got to the point where the chance of the game crashing approached certainty on any given turn, and since this crash could happen during the AI's turn as well, there was no way to alter your playstyle to prevent it from occurring. Disabling that reload flag fixed all of that, and at the time it did nothing beneficial.

Now, since then they've made a lot of improvements, and that flag now actually does something, so the crash issues might no longer be a major problem. But there's no question that it WAS causing crashes.
 
What is interesting is that Natural Wonders are Features, so it's really strange that the art doesn't work for other features. Also an interesting thing is that they are always impassable and don't have any visible terrain type. I'll try to modify the existing Natural Wonders to remove their Natural Wonder status and see what happens...
 
Yeah, it most certainly DID crash your game.
Hence my next sentence after the quoted one. There were many undocumented changes to graphics processing in all those patches after the initial bug was described. It's certainly a moot point in another 8 hours (at least for my modding). I'm going to assume that this feature works unless proven otherwise.

What is interesting is that Natural Wonders are Features, so it's really strange that the art doesn't work for other features. Also an interesting thing is that they are always impassable and don't have any visible terrain type. I'll try to modify the existing Natural Wonders to remove their Natural Wonder status and see what happens...

Oops! You're right, they are features. I guess I was remembering Civ4, where "Unique Features" were actually Improvements. I don't remember them having continent art types like other features though, so some of the suggestions above might still apply.
 
More strangeness: it doesn't work even when placing the original Natural Wonders in an unmodded game by a map script. I'll continue my investigation...

Oops! You're right, they are features. I guess I was remembering Civ4, where "Unique Features" were actually Improvements. I don't remember them having continent art types like other features though, so some of the suggestions above might still apply.

I think you mean FFH, there were no such things in base Civ4. Btw perhaps FFH was the source of inspiration for Firaxis to introduce Natural Wonders in Civ5. I think it's a good idea because it adds some nice graphics for the modders to use, but why it must be so complicated to use it? :(
 
Bad news. Using Natural Wonder graphics is severely restricted: for example the Volcano must have all adjacent hexes set to coast, and it only seems to work for the original feature (and NaturalWonder must be set to true), adding a new feature with the same properties won't work. Looks like lots of hardcoded stuff is going on here.

Why are you doing it to us, Firaxis? ;) Hopefully the DLL will shed some light on this mystery...
 
for example the Volcano must have all adjacent hexes set to coast, and it only seems to work for the original feature, adding a new feature with the same properties won't work. Looks like lots of hardcoded stuff is going on here.

Correct. This is all handled inside AssignStartingPlots; when certain Features are placed, the game will automatically modify certain nearby hexes to allow for the correct blending of graphics across the interface. For instance, the Rock of Gibraltar will be adjacent to a Mountain hex. This happens BEFORE the game tries to draw the map, and depending on the Feature type, the amount of changes can be pretty extensive.

Unfortunately, there's no way to modify these things on the fly, because every hex's graphics are blended with those of the six adjacent hexes, and so altering one hex would require recalculating at least six others. And it's not just terrain types, but Plot types (like Hills or Mountains) also affect the graphics of nearby hexes. This is why terraforming code (like my own) can't update the graphics to reflect the new terrain types; you can only tell the user to save and reload the game if he wants to see the correct graphics. We've been hoping for a "Refresh graphics" Lua function for a while now, but no luck yet.

So to the original point, yeah, most Feature graphics won't be usable mid-game... unless that particular Feature was DESIGNED to be added/removed as needed, like Forests or Jungles, which don't blend with terrain graphics at all. In general, this is something you need to be careful with, as you already know; you just have to stick with those graphics that don't require alteration of adjacent hexes.
 
I think you misunderstood me, I didn't mean adding a new feature during the game. All my terrain manipulations happen during the map creation, in the map script. The Volcano is not visible when not all adjacent hexes are Coast (or at the edge of the map). See the attached picture.

I meant adding a new feature to the mod, with all the same properties as the original Volcano, but a different name. This won't work. So the requirements for the Volcano to appear on the map are the following:

1. All adjacent hexes must be Coast or out of map.
2. Must be a Natural Wonder.
3. Must be named FEATURE_VOLCANO.

If any of these conditions is not fulfilled, only the fire and smoke will appear.

This really seems like hardcoded stuff...
 

Attachments

  • volcanoes.jpg
    volcanoes.jpg
    26.1 KB · Views: 90
It's not that bad after all. I guess I'll use normal Mountains with fire&smoke effect as Volcanoes, which doesn't look that bad actually, and my recent research shows that the natural wonders that were added later (like the Fountain of Youth), aren't so restrictive as the old ones, and can be used as graphics for normal features.
 
Back
Top Bottom