Quick Modding Questions Thread

Hello.

I am doing some trial and error things in CvMainInterface.py from the Better BUG AI mod, and I ran into this little thing:

CvMainInterface-py-missing-popup-on-mouse-hover.jpg


When in the City-screen: Popups from mouse-hovering over the Spy, Engineer, Merchant and Scientist is missing. All other popups-on-mouse-hover seems to be intact.

I suspect that somewhere in the game there is a cutoff for Y-values where these specialist-popups don't show. How that would work is not known to be at the moment.
When I hover the mouse slightly above the Artist, I can (for one or two pixels) see the popup for the Scientist. But moving the mouse a pixel too high it is gone again.

If you know where I need to focus my attention to find out how to solve this, I'll appreciate some tips.
 
Is it possible to make a unit more expansive with passing eras?

If the Civ4EraInfos.xml tag <iTrainPercent> does what is logical: Yes. If not: No, not to my knowledge.

If the above tag doesn't work, I guess you could ask somebody to make a Python-code.

EDIT: Of course, this would work for ALL units, not just one particular one.

EDIT2:
Just checked the modiki, this should work:

A - Civ4UnitInfos.xml
Make a unit require a building, and give building free at game's start.

B - Civ4EventInfos.xml
Can give/take away a building via an event.

C - Civ4EventTriggerInfos.xml
Can use OrPreReqs to trigger events when reaching next era.

Will need to play with events, or remove current events from files.
Will need one unique unit per era.
Will need one unique building per era.

Looks like a lot of work. Looks like it should work.
 
Last edited:
If the Civ4EraInfos.xml tag <iTrainPercent> does what is logical: Yes. If not: No, not to my knowledge.

If the above tag doesn't work, I guess you could ask somebody to make a Python-code.

EDIT: Of course, this would work for ALL units, not just one particular one.

EDIT2:
Just checked the modiki, this should work:

A - Civ4UnitInfos.xml
Make a unit require a building, and give building free at game's start.

B - Civ4EventInfos.xml
Can give/take away a building via an event.

C - Civ4EventTriggerInfos.xml
Can use OrPreReqs to trigger events when reaching next era.

Will need to play with events, or remove current events from files.
Will need one unique unit per era.
Will need one unique building per era.

Looks like a lot of work. Looks like it should work.
THX, but not exactly what I was looking for.
For some reason I thought that Workers get more expansive in the later game :rolleyes:
 
For me there is a more straightforward way, relatively easy in C++ :

First create a new XML Tag in the CvUnitInfo file, which you fill in for just the worker.
Say <iEraAdditionalCost>10</iEraAdditionalCost>


Then in C++ you need to "attack" the value of cost as early as possible, this is the function that reads the cost

Code:
int CvUnitInfo::getProductionCost() const           
{
return m_iProductionCost;
}

Then change this logic to say, to add a value calculated with :
GC.getGame().getCurrentEra() * this value of iEraAdditionalCost =
(Remember, "Ancient" = 0, Classical = 1 etc.).

Also, don't forget to check that the current era "exist" in the calc, otherwise you'll have an error in game menu / in civelopedia etc.
(GC.getGame().getCurrentEra() != NO_ERA)
 
For me there is a more straightforward way, relatively easy in C++ :

First create a new XML Tag in the CvUnitInfo file, which you fill in for just the worker.
Say <iEraAdditionalCost>10</iEraAdditionalCost>


Then in C++ you need to "attack" the value of cost as early as possible, this is the function that reads the cost

Code:
int CvUnitInfo::getProductionCost() const          
{
return m_iProductionCost;
}

Then change this logic to say, to add a value calculated with :
GC.getGame().getCurrentEra() * this value of iEraAdditionalCost =
(Remember, "Ancient" = 0, Classical = 1 etc.).

Also, don't forget to check that the current era "exist" in the calc, otherwise you'll have an error in game menu / in civelopedia etc.
(GC.getGame().getCurrentEra() != NO_ERA)
Thank you very much but editing the dll is beyond my reach :undecide:
Maybe if it was python, than I could merge it. Probably :rolleyes:
But thanks anyway. I'll find out something different :)
 
I think I may have asked this before but can’t find the answer- how do you convert an enumerator into an integrator?
 
Does the DLL control which sound is played when a unit retreats? If so, where? I can't find it in resolveCombat.
 
@Leoreth: AS2D_OUR_WITHDRAWL, AS2D_THEIR_WITHDRAWL
at the end of CvUnit::updateCombat (combat has ended but neither unit has died).

(@LPlate2: I don't know what is meant by "integrator". That said, if this is a graphics question, then what I don't know shouldn't worry you in the least. :D)
 
@Leoreth: AS2D_OUR_WITHDRAWL, AS2D_THEIR_WITHDRAWL
at the end of CvUnit::updateCombat (combat has ended but neither unit has died).

(@LPlate2: I don't know what is meant by "integrator". That said, if this is a graphics question, then what I don't know shouldn't worry you in the least. :D)
Predictive text kicking in on the mobile. I meant integer.
 
Conversion from an enum type to int should happen automatically. An example where an explicit cast can be useful: std::max takes a single template argument, so
EraTypes eEra = GC.getGame().getCurrentEra();
return std::max(1, eEra);
is ambiguous and results in a compilation error. Casting one of the arguments solves this problem:
return std::max(1, (int)eEra);
This also works:
return std::max<int>(1, eEra);
 
@Leoreth: AS2D_OUR_WITHDRAWL, AS2D_THEIR_WITHDRAWL
at the end of CvUnit::updateCombat (combat has ended but neither unit has died).
Nice, thanks! Should've checked updateCombat too.

Another question: is there a way to display player specific information in the bonus tooltip? I would like to display additional information in the diplo interface for each tradable resource. Such as for the resources the player owns something like "we gain happiness in X cities" (resources provide effects to a limited amount of cities in my mod) and for the resources the AI owns something like "we can gain happiness in X additional cities". There's a "eTradedPlayer" argument in setBonusTradeString, but it always seems to be -1 when hovering over resources in the trade table. Ideally I would like to know who "owns" the resource being displayed, or at least if it's current player vs. anyone else. I wouldn't mind changing higher level code to call setBonusTradeString differently. Is there a way to do this or am I out of luck because the diplo screen is being drawn by the exe?
 
Looks like the two player ids are available in CvDLLWidgetData:: parseTradeItem and just aren't passed along to CvGameTextMgr::setBonusHelp:
Spoiler :
Code:
void CvDLLWidgetData::parseTradeItem(
   CvWidgetDataStruct &widgetDataStruct, CvWStringBuffer &szBuffer)
{
   // ...
   if (widgetDataStruct.m_bOption)
   {
      if (gDLL->isDiplomacy())
         eWhoFrom = (PlayerTypes)gDLL->getDiplomacyPlayer();
      else if (gDLL->isMPDiplomacyScreenUp())
         eWhoFrom = (PlayerTypes)gDLL->getMPDiplomacyPlayer();
      eWhoTo = kGame.getActivePlayer();
   }
   else
   {
      eWhoFrom = kGame.getActivePlayer();
      if (gDLL->isDiplomacy())
         eWhoTo = (PlayerTypes)gDLL->getDiplomacyPlayer();
      else if (gDLL->isMPDiplomacyScreenUp())
         eWhoTo = (PlayerTypes)gDLL->getMPDiplomacyPlayer();
   }
   // ...
   case TRADE_RESOURCES:
      GAMETEXT.setBonusHelp(szBuffer, (BonusTypes)widgetDataStruct.m_iData2);
      // ...
eTradePlayer comes from BULL's WIDGET_PEDIA_JUMP_TO_BONUS_TRADE ("Resources" tab of the Foreign Advisor). Should indeed be -1 in all other contexts.
 
How would you get the calculated travel distance by sea from one plot to another?

I’m considering using @Kathy’s Panama Canal model but don’t want it to be buildable in a location where it won’t offer a significant reduction in the travel distance for ships.
 
@LPlate2: CvMap::calculatePathDistance
This lets the pathfinder (in the EXE) use the stepValid function (CvGameCoreUtils) to decide whether a step between two adjacent plots is allowed – which basically allows only steps within the same CvArea. The cost function is stepCost, i.e. a uniform cost of 1 per step.

The pathfinder may run through all plots in a water area, e.g. when there is no path because of sea ice; so that can be computationally expensive. Perhaps there's some cheaper condition that you could check beforehand. E.g. you could go in a circle through all 8 plots adjacent to a city and increase a counter each time that you reach a water plot from a land plot or vice versa. If the counter is 2 or less, then the city doesn't "really" act as a canal. ASCII sketch:
Spoiler :
Code:
 - - -
|L|L|L|
 - - -
|W|C|L|
 - - -
|W|W|W|
 - - -
Only two land/water transitions when circling the city.
Well, probably better to first check in a profiler whether there's a problem at all.
 
I would like to add the "Field of view" thing for my MOD.


It's part of BUG of course, but there are so many mods using it, is there a MODCOMP for it ? I'm not finding it...
It would be much easier than reverse engineer in BUG where it was done
 
Could someone point me in the direction of a tutorial for how to create a new civ? I had an idea for a mod that adds the 50 us states as civs.
 
Is it possible to have different set of music for eras, like in Civ5? Some track would be played only if you are at war with someone, others only if you are at peace with everyone and the rest can be played in either cases.
 
Back
Top Bottom