• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

[Development] Alternative Map during 1.17

For things such as different cattle breeds (if that's implemented, as someone was suggesting), I think just seeing different colors/forms of the resource like here, would be perfect. But for things such as dyes, where what you actually want is different things (ie, murex vs indigo), I think it would nice to also show that in the tooltip as "indigo (dyes)" or "murex (dyes)". I'm not sure about whether having "(dyes)" under parenthesis would be necessary, but it's perhaps useful when it's not obvious what these things are for. A nicer alternative would be to have to go to the civilopedia to find out what these resources are for.
 
The stunning conclusion:

I successfully implemented that you can have one resource on a tile that for all intents and purposes behaves like itself except that it is displayed on the map as another resource. Like here, the cursor is over the tile that looks like Amber but the tooltip still shows it as the salt resource it actually is.

The next step is adding a bunch of dummy resources that are bGraphicalOnly and function as varieties for existing proper resources. Since their stats never matter unless they are placed as proper resources on the map, this should have no impact on the game.

The only trouble I can foresee is if the variety expects a different improvement (i.e. the base resource is land based and the variety is maritime, which I already intend for Dye), but otherwise all that's missing is including this into the WBSave file. Next step is digging into a bunch of other mods and the download database for resources that are interesting candidates for this.

Can you explain in general what you did to achieve this? I'm quite curious.

I don't think that multiple improvements are a problem if the domain is different. Take oil for example. It has 2 improvements that provide it, but the domain restriction prevents building the wrong improvement. I can see problems if the domain is the same. (orchard - plantation for example)
 
For things such as different cattle breeds (if that's implemented, as someone was suggesting), I think just seeing different colors/forms of the resource like here, would be perfect. But for things such as dyes, where what you actually want is different things (ie, murex vs indigo), I think it would nice to also show that in the tooltip as "indigo (dyes)" or "murex (dyes)". I'm not sure about whether having "(dyes)" under parenthesis would be necessary, but it's perhaps useful when it's not obvious what these things are for. A nicer alternative would be to have to go to the civilopedia to find out what these resources are for.
The more interesting question is ... is Saffron a spice or a dye?

Can you explain in general what you did to achieve this? I'm quite curious.
So what I found out is that there is no way to give multiple art defines to a bonus (resource). The exe just retrieves the bonus type from the DLL and then renders it using the provided art defines. However, initially I thought the exe just uses CvPlot::getBonusType() to do that, because that function is exported to the DLL. But instead there is something like CvPlot::getVisibleTileImprovements(...) or similar, which controls the bonus, improvement and route to be rendered on a given tile (because techs revealing resources and fog of war play into this, which are in the domain of the DLL).

So I thought I cannot control how a bonus is rendered but I can make the engine render a different bonus than is actually on the tile. I added CvPlot::getBonusVarietyType(), which can be set through Python, and if it's not NO_BONUS, the bonus stored in this member variable is displayed instead. I left the rest of the code unchanged so CvPlot::getBonusType() still controls everything else as far as the game rules are concerned.

I don't think that multiple improvements are a problem if the domain is different. Take oil for example. It has 2 improvements that provide it, but the domain restriction prevents building the wrong improvement. I can see problems if the domain is the same. (orchard - plantation for example)
True, it's only a problem because the actual resource still controls which improvements can be built so for e.g. Murex I need to add fishing boats to the original Dye resource to make this happen. So it becomes a problem only if they are in the same domain, but that's not very likely because in that case it should really be two separate resources.
 
So what I found out is that there is no way to give multiple art defines to a bonus (resource). The exe just retrieves the bonus type from the DLL and then renders it using the provided art defines. However, initially I thought the exe just uses CvPlot::getBonusType() to do that, because that function is exported to the DLL. But instead there is something like CvPlot::getVisibleTileImprovements(...) or similar, which controls the bonus, improvement and route to be rendered on a given tile (because techs revealing resources and fog of war play into this, which are in the domain of the DLL).

So I thought I cannot control how a bonus is rendered but I can make the engine render a different bonus than is actually on the tile. I added CvPlot::getBonusVarietyType(), which can be set through Python, and if it's not NO_BONUS, the bonus stored in this member variable is displayed instead. I left the rest of the code unchanged so CvPlot::getBonusType() still controls everything else as far as the game rules are concerned.

So you introduce many dummy resources to represent the varieties?
 
Yes, one dummy resource for each variety. There's no way around that part because the exe expects an actual resource to render on the map.
 
I have some succes of my own regarding the bonus varieties. I modified my previously failed attempt a bit and now it works properly. It more or less mimic giving multiple artdefine tags to a bonus.

I modified the BonusInfoXML so it we can easily assign multiple artdefines. All artdefinetags are stored in the CvBonusInfo() class.

Spoiler :
Code:
        <BonusInfo>
            <Type>BONUS_SHEEP</Type>
            <Description>TXT_KEY_BONUS_SHEEP</Description>
            <Civilopedia>TXT_KEY_BONUS_SHEEP_PEDIA</Civilopedia>
            <BonusClassType>BONUSCLASS_LIVESTOCK</BonusClassType>
            <ArtDefineTag>ART_DEF_BONUS_SHEEP</ArtDefineTag>
            <VarietyArtDefineTags>
                <VarietyArtDefineTag>ART_DEF_BONUS_SHEEP_LLAMA</VarietyArtDefineTag>
            </VarietyArtDefineTags>
            <TechCityTrade>TECH_PASTORALISM</TechCityTrade>
            <TechPlayerTrade>TECH_REFRIGERATION</TechPlayerTrade>
            <YieldChanges>
                <iYieldChange>1</iYieldChange>
            </YieldChanges>
....

I created 3 new functions based on what you did for the cityscreenOwner.

Spoiler :
Code:
void CvGame::setBonusVariety(int iVariety)
{
    m_iBonusVariety = iVariety;
}

void CvGame::resetBonusVariety()
{
    m_iBonusVariety = 0;
}

int CvGame::getBonusVariety() const
{
    return m_iBonusVariety;
}

This creates some kind of global variable. I use this variable in CvInfos to obtain the artdefinetag.

Spoiler :
Code:
const CvArtInfoBonus* CvBonusInfo::getArtInfo() const
{
    // Merijn: Bonus varieties
    int iVariety = GC.getGameINLINE().getBonusVariety();
   
    if (iVariety > 0 && iVariety < m_iNumVarieties + 1)
    {
        return ARTFILEMGR.getBonusArtInfo( getVarietyArtDefineTag(iVariety-1));
    }
    return ARTFILEMGR.getBonusArtInfo( getArtDefineTag());
}

I added GC.getGameINLINE().setBonusVariety(getBonusVariety()); in the CvPlot::getVisibleBonusState() function. When the game tries to get the bonus graphics of a certain tile, it temporarily sets my new "global variable" to the bonus variety. With the changes I made in CvInfos.cpp, it will load the artdefinetag based on the variety.

I added GC.getGameINLINE().resetBonusVariety(); to CvPlot::setLayoutDirty(bool bDirty) when bDirty is False. (Which I think is what the engine uses when the plot graphics are build)

It works like a charm and doesn't require any dummy resources.
 
Not sure what to think about that, first of all abusing global variables like this is concerning from a software engineering perspective (i.e. having functions rely on behaviour out of their scope). But more importantly I think this will result in a lot of operations just to draw the main screen (i.e. constantly setting and resetting the current bonus variety). I'm not sure how often the screen is redrawn if layoutDirty comes into play (I guess only when it is set to dirty), but this is still more than I'm comfortable with really. It's much better design to have the graphical varieties local to each plot.
 
I understand. I learned a few new things from doing this and it was fun to do, so it wasn't for nothing. And maybe some of my code can be used with your method.
 
Last edited:
About resource varieties, I have the following right now:
- Dye (Murex)
- Dye (Henna)
- Spices (Saffron)
- Spices (Vanilla)
- Gems (Turquoise)
- Gems (Diamonds)
- Gems (Rubies)
- Gems (Sapphires)
- Sheep (Llama)
- Cow (brown)
- Pigs (furry)

Do people know any other alternative resource art? I'd love more varieties for spices in particular, like cinnamon, cloves, nutmeg ...
 
African bush elephant. Slightly bigger and a brownish hue. IIRC there is no art available, but I planned to make it myself.

Crab: lobster, shrimp. (C2C has art)
Maybe rename the resource to shellfish.

For nutmeg, you could use the pistacio and make recolor the inner part of the nut red. https://forums.civfanatics.com/resources/pistachio-resource.17447/
Cinnamon could be a reskin of the bamboo trees perhaps.

Banana: There are many (tropical) fruit resources available in the database.

I haven't created my own resources, but I would like to give it a try. I can't do animations, but I (think I) can use animations of existing models.
 
Last edited:
I know there are a lot of fruit varieties in the database, but they are all just a very simple palm tree with (imo) too obtrusively rendered fruit models copy/pasted. Also, I intend to make Citrus and Palms/Dates separate resources in the future so we don't have to address them at the moment.

Reskins of existing models are always a good idea, I would love to have alternative Horse art for example, or a deer variety that looks more like gazelles.
 
I'm quite sure I've seen a deer resource that's slightly different - it's kind of bigger, looks more like reindeer, so that could work (In c2c i believe). If deer is representing game meat, then that could be extended to other animals - you mentioned gazelles, but perhaps even rhinos? zebras? crocodiles?

The red cochineal dye is taken from a shield bug that grows and feeds on the prickly pear cactus - there's no bug graphics, but there's graphics for the cactus (as a resource in c2c), so you could use that one.

I'm wondering if we should add chicken as a variety to pigs, since they basically function in the same way (eat scraps, provide meat).

There's also flax art that can be used as a variety for cotton; and coke plant art that can be a variety for opium (also hemp, but that also has textile uses, maybe it should be different).

And there's seal / walrus art that can serve as a (land-based?) variety for whales.
 
The red cochineal dye is taken from a shield bug that grows and feeds on the prickly pear cactus - there's no bug graphics, but there's graphics for the cactus (as a resource in c2c), so you could use that one.
I would love Cochineal as a new world dye, let's see if that works.

There's also flax art that can be used as a variety for cotton; and coke plant art that can be a variety for opium (also hemp, but that also has textile uses, maybe it should be different).
Considered Flax, but Cotton isn't really present on the map where Flax would be and a geographical limitation for Cotton is better I think. There is both Coca and Peyote art, but if those are conflated with Opium the resource should probably be renamed.

IIRC Realism Invictus uses a reskinned horse model.
Oh good, I will check.
 
New update: introduced graphical varieties for resources (see above for a list)

Here are a couple of examples:
Spoiler :
Civ4ScreenShot0082.JPG
Civ4ScreenShot0083.JPG
Civ4ScreenShot0084.JPG
Civ4ScreenShot0085.JPG
Civ4ScreenShot0086.JPG

We have Saffron and Turquoise in Persia, Murex in the Mediterranean replacing land based Dye resources, Diamonds in South Africa, and Llamas in the Andes.

There's still a bunch of stuff to do that I will leave to the interested reader as I am moving on to other stuff, such as:
- resources that are graphical varieties should not show up in civilopedia as resources or in the resources menu in worldbuilder
- worldbuilder needs a new section to set graphical resource varieties
- the DLL code needs to be checked if there is code iterating all resource types so that it ignores bGraphicalOnly resources
- the Llama model is not animated, but I saw an animated alternative in the database that we could try

Of course, the present changes to the map are just examples, providing the opportunity for further suggestions to apply them. However, the main purpose is not to add more resources but to change the graphical appearance of existing resources. As discussed above, I am also still looking for further varieties if there is art available.

I plan to come back to this later but there is also other stuff that I want to turn my attention to in the meantime.
 
- resources that are graphical varieties should not show up in civilopedia as resources or in the resources menu in worldbuilder
- worldbuilder needs a new section to set graphical resource varieties

I had some thoughts how this can be done. (I coded this in my own attempt and I think it can be used here as well)

Step 1. Add some xml attribute. It will only be used in the default resource and it defines which bonusses are variants of it. (see last xml attributes)

Spoiler :
Code:
        <BonusInfo>
            <Type>BONUS_SHEEP</Type>
            <Description>TXT_KEY_BONUS_SHEEP</Description>
            <Civilopedia>TXT_KEY_BONUS_SHEEP_PEDIA</Civilopedia>
            <BonusClassType>BONUSCLASS_LIVESTOCK</BonusClassType>
            <ArtDefineTag>ART_DEF_BONUS_SHEEP</ArtDefineTag>
            <TechCityTrade>TECH_PASTORALISM</TechCityTrade>
            <TechPlayerTrade>TECH_REFRIGERATION</TechPlayerTrade>
           ...
            <BonusVarietyTypes>
                <BonusVarietyType>BONUS_SHEEP_LLAMA<BonusVarietyType>
                <BonusVarietyType>BONUS_VAR2<BonusVarietyType>
                etc...
            </BonusVarietyTypes>
        </BonusInfo>

Step 2: Modify CvPlot::setBonusType
It will have an additional argument: int variety. This value will be used to obtain the BONUS_TYPE defined in the new xml attribute and this will be used in the CvPlot::setBonusVarietyType function you created.

This makes setBonusType behave the same as setFeatureType, which is I think very convenient. We also don't need a new WB section. Instead, we can use the layout of terrain feature section. (I can make the variety dropdown show the name of the variety, instead of only the variety number.)

My idea for the pedia section is to add new buttons (on the default resource page). You can select which variant is displayed with these buttons. The pedia code uses screen.addBonusGraphicGFC() to display the graphics. It requires a bonusType as input argument. We can create a new function BonusType CvBonusInfo::getBonusVarietyType(int variety) to obtains the bonusType defined in the new xml attribute.

Thoughts?
 
That's awesome!

There might be some required adjustments in resource spawn dates to do eventually. For instance, if there are spices in Madagascar and Réunion representing vanilla (and there should), they should appear only in the 19th century.
 
I had some thoughts how this can be done. (I coded this in my own attempt and I think it can be used here as well)

Step 1. Add some xml attribute. It will only be used in the default resource and it defines which bonusses are variants of it. (see last xml attributes)

Spoiler :
Code:
        <BonusInfo>
            <Type>BONUS_SHEEP</Type>
            <Description>TXT_KEY_BONUS_SHEEP</Description>
            <Civilopedia>TXT_KEY_BONUS_SHEEP_PEDIA</Civilopedia>
            <BonusClassType>BONUSCLASS_LIVESTOCK</BonusClassType>
            <ArtDefineTag>ART_DEF_BONUS_SHEEP</ArtDefineTag>
            <TechCityTrade>TECH_PASTORALISM</TechCityTrade>
            <TechPlayerTrade>TECH_REFRIGERATION</TechPlayerTrade>
           ...
            <BonusVarietyTypes>
                <BonusVarietyType>BONUS_SHEEP_LLAMA<BonusVarietyType>
                <BonusVarietyType>BONUS_VAR2<BonusVarietyType>
                etc...
            </BonusVarietyTypes>
        </BonusInfo>

Step 2: Modify CvPlot::setBonusType
It will have an additional argument: int variety. This value will be used to obtain the BONUS_TYPE defined in the new xml attribute and this will be used in the CvPlot::setBonusVarietyType function you created.

This makes setBonusType behave the same as setFeatureType, which is I think very convenient. We also don't need a new WB section. Instead, we can use the layout of terrain feature section. (I can make the variety dropdown show the name of the variety, instead of only the variety number.)

My idea for the pedia section is to add new buttons (on the default resource page). You can select which variant is displayed with these buttons. The pedia code uses screen.addBonusGraphicGFC() to display the graphics. It requires a bonusType as input argument. We can create a new function BonusType CvBonusInfo::getBonusVarietyType(int variety) to obtains the bonusType defined in the new xml attribute.

Thoughts?
Not sure if you've already looked into the code, but that's not necessary. The DLL now already exposes CvPlot::setBonusVarietyType(BonusTypes eBonus), there just needs to be world builder functionality for that. All actual resources have bGraphicalOnly as false, the variety dummy resources have bGraphicalOnly set as true. It's basically just two different buttons in the main worldbuilder interface that can set actual resources (the current button with dummy varieties filtered out) and a new one that sets the variety bonus type for a tile. There is no explicit link which varieties are "meant" for which real resource but I don't think it's necessary and it only complicates the implementation.

That's awesome!

There might be some required adjustments in resource spawn dates to do eventually. For instance, if there are spices in Madagascar and Réunion representing vanilla (and there should), they should appear only in the 19th century.
I completely agree, the spread of spices around the world is poorly modeled at the moment, which is probably because the umbrella term "spices" makes it hard to tell which spices are actually meant by the ones placed on the map. As soon as they are vanilla explicitly it makes it easier to account the spawns for it. I actually have rough outlines about the native and spread regions for the spice varieties I mentioned above prepared so I would really like to make use of them.

But also conversely more resources should expire. All the murex locations are prime candidates for that, leaving Europe and the Mediterranean without Dye, giving further motivation to colonise.
 
Back
Top Bottom