Events are a Two-Way Street

Crap. This is awesome!

EDIT: Ok I can't replicate it.
Here is what I'm doing: I am getting the right plot, typing the event (Events.SerialEventImprovementCreated(106, 40, 4, 4, 0, 37, -1, 3, 4)) on a state other than the Main one, building an Improvement (with IGE) but it doesn't change it.
 
Crap. This is awesome!

EDIT: Ok I can't replicate it.
Here is what I'm doing: I am getting the right plot, typing the event (Events.SerialEventImprovementCreated(106, 40, 4, 4, 0, 37, -1, 3, 4)) on a state other than the Main one, building an Improvement (with IGE) but it doesn't change it.

You'll need to build the improvement and then manually call the event
 
You have to change int createImprovementType
(Events.SerialEventImprovementCreated(106, 40, 4, 4, 0, 37, -1, 3, 4)

after you've placed the improvement

To be sure of having the right coordinates, maybe is better to use the listener, copy/paste the arguments, than change the number in bold.
 
Remember coordinates are hex (as is always the case for graphics stuff). Listener will make sure you get the right numbers there.

What's still a mystery to me are the IDs for createImprovementType (a misnomer since this isn't only about improvements). Specifically, are these derived from external data (for example ArtDef tables) in some way that's hard to understand, or are they hard-coded in graphics engine. Knowing that would tell us if we can add new graphics versus just change existing graphics. (Even the latter is something ... e.g., we can't currently update NW graphics in-game.)
 
I don't know if I understood correctly but if you see post #18, there's something that maybe is related to this matter.

When I first tested I used a modded game (my project) who adds new improvements (and new arts): this made the improvements numbers change: the Fort was 44 and Chateau was 37

While in an unmodded game the Fort is 37 and the Chateau is 31.

Now, I don't know at which conclusions we can get with this and these are obviously newbie considerations, but, it is possible that the game insert the new arts in the list giving improvements new numbers ?
I hope this info contribute to find an answer...
 
Spoiler :
00 - Atoll - It has more than one graphic
01 - I can't replicate
13 - Scorch? Bit of Oil?
64 - Aluminium
65 - Aluminium (big reserve)
71 - Coal
72 - Coal (same)
73 - Coal (less)
74 - Orange trees?
75 - Copper
76 - Cotton, I assume
77 - Cows (already trapped) **
78 - Fishing boat (on Crabs) *Comes with FX too! **
79 - -//-
80 - Dyes
81 - 78 (on Fish)
82 - Fur (trapped) **
83 - Fur (trapped) **
-- From here on, it seems all of them are ** --
84 - Gems (bits)
85 - Gold (bits)
86 - Ancient Ruins
87 - Horses (trapped, stone)
88 - Incense
89 - Iron (bits)
90 - Iron
91 - Iron
92 - Iron (bits)
93 - Elephants (trapped)
94 - Marble
95 - Oil (land)
95 - Oil v2 (land)
97 - Oil (water)
98 - Oil v2 (water)
99 - Fishing Boat (another Luxury)
100 - Salt


There are plenty more, for sure, but I can't go on right now.
Cheers!

**Same problem as the polder and bisonts. It appears as they have different 'levels', because some of these graphics can be replaced by others on the same supposed level.
On the same note, maybe what we saw was that every graphic of the first list, with the exception of Polder and Bisons were on the same level!
 
@Ulixes, No, you understood perfectly. Your observation tells us that these IDs are generated (somehow) from external data. Or possibly a mix of external data and hard-coded data.

Edit: @bane_, well, what comes after 100...? ;)

So the list is a strange mix of improvements, features (including but not only natural wonders), resources, and unknowns. And it's not complete so who knows what? Improvements and resources are linked to graphic model (fxsxml file) in ArtDefine_Landmarks. But there is a lot in that list that is not in this table at all. I wonder if including fxsxml file alone (with vfs=true) is sufficient to end up in this list? But that's hard to understand because then we would see units too (although maybe they are there past 100?).

Don't have access now, but does anyone know if these variants are all in the ArtDefine_Landmarks table?:
58: trading post
59: trading post (ver 2)
60: trading post (ver 3)
61: trading post (ver 4)

To get back to your original request for cultural variation of improvements:

OK, this is a "hack", but the basic outline for modding improvements with cultural variation is:
  1. Add the improvement art assets for the cultural variants you want in each era (by assets I mean gr2, fxsxml, dds files), with VFS=true
  2. Get them to "show up" as an ID in that mysterious list somehow. That may or may not require adding them to the ArtDefine_Landmarks table (we just don't know). Unless someone figures out the logic behind this list, it is simply a search and find effort.
  3. Write down ID in that list for the "base" improvement (the one that workers actually build) and all of your cultural variants.
  4. Make code (analogous to my OP code) that listens for the base improvement and (when detected) immediately replaces it with the cultural variant.
The step I can help with is #4.

Let me repeat again that this is a "hack". One problem is that it would stop working if the IDs changed, which would be the case for many mods or for each of the expansions. To deal with this properly we would have to understand the logic behind this list so that we could generate the proper ID ourselves given game data.



----------------------------------------
No answers, but more questions if anyone wants to pursue:

I'm just curious if the createResourceType in the args list below is identical to the ID list above. In other words, if you set up a listener with this Events, then plopped a resource (as above), then played with arg #6, would it be the same exact list as above?
Code:
SerialEventRawResourceCreated(float hexX, int hexY, ArtStyleType continent, ArtStyleType continent, PlayerID player, int arg5, int createResourceType, int arg7, int arg8)

Same question again for "routeType":
Code:
SerialEventRoadCreated(int hexX, int hexY, PlayerID player, int routeType)

Same question again for "unitType" (I know from testing that this is not ID from Units table; i.e., not equal to unit:GetUnitType()):
Code:
SerialEventUnitCreated(PlayerID player, UnitID unitID, int hexVec, int unitType, int cultureType, int civID, int primaryColor, int secondaryColor, int unitFlagIndex, int fogState)
 
[...]
Don't have access now, but does anyone know if these variants are all in the ArtDefine_Landmarks table?:
[...]

Yes.

Specifically, there are Art Defines for:
  • ART_DEF_IMPROVEMENT_TRADING_POST1
  • ART_DEF_IMPROVEMENT_TRADING_POST2
  • ART_DEF_IMPROVEMENT_TRADING_POST3
  • ART_DEF_IMPROVEMENT_TRADING_POST4
 
Thank you for the help bane_! :)
I think I've finished the list! It seems to stop at 116

Spoiler :
101: Sheep Pasture (ancient)
102: silk
103: light blue mineral
104: spices?
105: stone
106: sugar
107: horses (improved)
108: pigs (truffles) with camp
109: uranium
110: uranium
111: other green stuff but on light terrain (uranium)
112: green stuff again (uranium) ???
113: fishing boat
114: wheat
115: wine
116: whale and boat


About Trading Posts:
I don't want to go too much off topic, but I did an experiment some time ago that maybe is worth mentioning:
as DarkScythe said, those 4 are the TP variants in art defines

I imported in my project the old TP art (remember, the one in the game without expansion?).
I put all 4 variants in art defines trying to replicate TP effect for my new improvement: as you already know the trading post not only change appearance with era, but as also 4 variants randomly generated.
If you see the database the TP art define is ART_DEF_IMPROVEMENT_TRADING_POST, but there's no table who connect this tag to the 4 previously mentioned.
If I write "RANDOM" in LayoutHandler I have the random generation between the 4 TP versions but NOT the era change.
So, I had simply to rename the text key of the vanilla TP and use this as my new improvement.

Maybe someone knows more than me how TP works and could explain it to me

As always, this is newbie consideration, but maybe, to understand how exactly the random generation happens can help to understand this puzzle (or viceversa) and ultimately allow cultural variation for improvements (and probably much more).

I'll probably try with the questions you made and I'll make some test on modded game.
 
Can I assume that the above lists (Ulixes and bane_'s) were generated in an unmodded BNW game? Well, I know you added the listener. But no other mods to any tables anywhere?

If so, I'm going to try to make some sense of it from various DB tables. May or may not be a futile effort.


Edit:
Interesting! All of the "features" in the list are the features that appear in the ResourceType column in ArtDefine_Landmarks: atoll, fallout, oasis and NWs, but not forest, jungle, marsh, ice.
 
PERFECT MATCH ! :thumbsup:

I tried SerialEventRawResourceCreated

"int createResourceType" numbers are the same!

Spoiler :
Aluminium (65)
Bananas (67)
Citrus ("Lemons" 69)
Coal (71)
Copper (75)
Cotton (76)
Cattle (77)
Crab (78)
Deer (79) not confirmed
Dyes (80)
Fish (81)
Fur (82)
Gems (84)
gold (85)
Incense (88)
Iron (90)
Ivory (93)
Marble (94)
Oil (96)
Oil on Sea (97)
Pearls (99)
Salt (100)
Sheep (101)
Silk (102)
Silver (103)
Spices (104)
Stone (105)
Sugar (106)
Horses (107)
Truffles (108)
Uranium (110)
Whales (113)
Wheat (114)
Wine (115)


About the list: My list is from an unmodded game, except the listener and IGE.
I think bane_'s too, since our numbers seem to match, but maybe is better to wait his confirmation.
 
I used a barely modded game, with the Civ I was testing and the listener.
I will re-check the 115 and see if this new-generated list without any mods checks with Ulixes', just so I don't give false information with my previous list.

I've been thinking about the unreplaceability of some graphics as first discovered by Ulixes, I'll post what I think tomorrow, after I've slept on it. :)
 
PERFECT MATCH ! :thumbsup:

I tried SerialEventRawResourceCreated

"int createResourceType" numbers are the same!
I'm sure what we are looking at is the graphic engine's internal representation of "Landmark Objects", which includes improvements, resources (and some specific combinations of improvement+resource), and some but not all features. I think it is derived from ArtDefine_Landmarks table in some way, but not directly.

SerialEventRawResourceCreated and SerialEventImprovementCreated are triggered when active player sees a change in resource or improvement (respectively) and either event tells you the "Landmark Object" ID at that plot.
 
This certainly presents a unique opportunity for more game immersion. Nice find, Pazyryk. :thumbsup:

So... I'd like to make a function which fires when a city is built (GameEvents.PlayerCityFounded). The function would check what the city's name is (using City.GetName(), which has been a functional method in one of my mods but for some reason is not listed in the reference) and if it matches a specific string, would manually override that specifically that city's art style.

Does it matter what SerialEvent I use? Does it have to line up with the same trigger as the event hook - the construction of a city - and hence be Event.SerialEventCityCreated? Or can it be any SerialEvent dealing with cities?
I assume I can ignore all the event's parameters except for cityID and artStyleType, so it would look like this...?
Code:
...
Events.SerialEventCityCreated(_, _, pCity, ArtStyleTypes.ARTSTYLE_EUROPEAN)
-- assuming pCity is already defined
...

Furthermore, to clarify, I'll need to create a second function which will fire on city conquest, doing much the same thing, in order to retain this change? And another that will fire on game load? What event hook can you recommend for dealing with the graphic engine that fires when the game loads? And finally - a naïve question, but - is the listener really necessary to make this work?

TIA,
AW
 
I'm not a Lua expert so I leave to Pazyryk any consideration on your Lua code,
but, if you are considering to use what we found here, keep in mind that art numbers change if you add new art or if they are added by another mod (AFAIK).

New improvements / resources art change the numbers for sure, I think also new features / terrain art.

It's not clear how and personally, this is what stopped me to go further with my plans with improvement graphic (and a massive lack of time too).
If I understood correctly, you have to do it last, when you're sure you have included all the arts you wanted and it will not be compatible with mods that add other arts.

Furthermore, maybe you can do it anyway, but, reading old posts, I noticed the city art-styles weren't among the numbers (we tried all of them, there was nothing after 116, I tried till 130-140 I think).
 
Top Bottom