[PYTHON] Science python rule

Discussion in 'Civ4 - SDK/Python' started by Darkator, Jul 28, 2021.

  1. Darkator

    Darkator Warlord

    Joined:
    Sep 18, 2020
    Messages:
    140
    Gender:
    Male
    Location:
    Poland,EU
    Can you create a python rule that divides your team's research points by the number of allies in your alliance?
     
  2. raystuttgart

    raystuttgart Civ4Col Modder Supporter

    Joined:
    Jan 24, 2011
    Messages:
    7,513
    Gender:
    Male
    Location:
    Stuttgart, Germany
    I can not imagine how that should work in Python. Also it would not be very performant.
    All of the Yield generation logic is in DLL (source code) and normally not made accessible to Python.

    But in DLL such "Yield calculation rules" are a piece of cake.
    (We have lots of such rules in "We the People".)

    Summary:
    Go for DLL.
     
  3. Darkator

    Darkator Warlord

    Joined:
    Sep 18, 2020
    Messages:
    140
    Gender:
    Male
    Location:
    Poland,EU
    the problem is that my mod is already based on one dll (32 more civilization)
     
  4. raystuttgart

    raystuttgart Civ4Col Modder Supporter

    Joined:
    Jan 24, 2011
    Messages:
    7,513
    Gender:
    Male
    Location:
    Stuttgart, Germany
    Is the source code of that DLL not available?
    Otherwise I do not really understand the general issue.

    Why not simply modify the source code of "32 more civilization" by putting your changes in it and compile it again?
    You would still have only one DLL but it will simply be "32 more civilizations + darkator changes".
     
    Last edited: Jul 30, 2021
  5. Darkator

    Darkator Warlord

    Joined:
    Sep 18, 2020
    Messages:
    140
    Gender:
    Male
    Location:
    Poland,EU
    and here's the problem, i can barely know python, let alone dll, and i don't have dll source code.
     
  6. raystuttgart

    raystuttgart Civ4Col Modder Supporter

    Joined:
    Jan 24, 2011
    Messages:
    7,513
    Gender:
    Male
    Location:
    Stuttgart, Germany
    Well ok, if you do not even have the source code then this option is of course dead.
     
  7. Darkator

    Darkator Warlord

    Joined:
    Sep 18, 2020
    Messages:
    140
    Gender:
    Male
    Location:
    Poland,EU
    can this function (changeResearchProgress()) reduce the speed of research?
     
  8. f1rpo

    f1rpo plastics

    Joined:
    May 22, 2014
    Messages:
    1,019
    Location:
    Germany
    Might be possible to accomplish what you want through the
    TECH_COST_EXTRA_TEAM_MEMBER_MODIFIER
    value in GlobalDefines.xml. Here's how the DLL uses that value (slightly edited for readability):
    Code:
    int CvTeam::getResearchCost(TechTypes eTech) const
    {
       int iCost = GC.getTechInfo(eTech).getResearchCost();
    
       // (... apply a bunch of other percent modifiers ...)
    
       iCost *= std::max(0, 100 +
             GC.getDefineINT("TECH_COST_EXTRA_TEAM_MEMBER_MODIFIER") *
             (getNumMembers() - 1));
       iCost /= 100;
    }
    On a side note, if your DLL only increases the civ limit, then you could simply use the source code of the original DLL and increase the civ limit there; it's a one-line change in CvDefines.h. However, setting up the environment for recompiling the DLL is a bit laborious, so, hopefully you can get it to work through XML/ Python.
     

Share This Page