1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Quick Modding Questions Thread

Discussion in 'Civ4 - Creation & Customization' started by kiwitt, Jan 27, 2010.

  1. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,539
    Gender:
    Male
    Location:
    Canberra, Australia
    As far as I can see that is not a standard BtS tag. It could be from Revolutions, or Dale's mods, or Afforess' stuff for RoM. Checked does not look like it is Afforess's stuff.
     
  2. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,934
    Gender:
    Male
    Location:
    In a constant brainstorm...
    I don't know it's origin but it is in C2C too. Sometimes it's 50, other times it's 100.
     
  3. Kjotleik

    Kjotleik Kjotleik

    Joined:
    Feb 22, 2010
    Messages:
    419
    Gender:
    Male
    Location:
    Norway
    CIV4UnitInfosBTS319-HorseArcher.jpg

    From the CIV4UnitInfos.xml in BTS 3.19. This is the Horse Archer entry.

    My guess is that it is the strength of the unit (in % compared to the iCombat tag) when doing flanking-damage to the particular unit mentioned in the FlankingStrikeUnitClass.

    If not, the developers didn't name their tags using common sense...
     
    Last edited: Apr 22, 2020
    Zeta Nexus likes this.
  4. merijn_v1

    merijn_v1 Black Belt

    Joined:
    Dec 29, 2008
    Messages:
    5,800
    Location:
    The city of the original vlaai
    iFlankingStrength determines the amount of damage done to the flanked unit compared to the damage done to the attacked unit. It uses the following formula:
    Flankdamage = (40 * iFlankingStrength) / 100

    So if you attack a unit and do, let's say, 40 hitpoints damage, you will also do 40 hitpoints damage to the flanked units. If you have a flankingstrength of 50, you will only do 20 hitpoints damage to the flanked units.
     
    Zeta Nexus likes this.
  5. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,399
    Gender:
    Male
    Location:
    Leblanc
    How does the game load Python modules? For the longest time I assumed it would simply load all *.py files in the Python folder, but that does not seem to be true. Usually a module is imported by another module which ensures it being loaded, so there's not much of a difference.

    However, recently I learned that the BugEventManager allows having functions subscribe to an event, which is much cleaner than having a central module delegate event calls into submodules. The only issue is, when all a module does is subscribe to and handle a bunch of DLL events, there's no need for another module to import it, so it doesn't get loaded.

    Of course I could import it from any arbitrary other module, but that kind of defeats the purpose of doing decentralised event handling like that. So how does the game go about loading modules? Where does it start? I would at least like to keep my dependency tree short with those modules.
     
  6. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,399
    Gender:
    Male
    Location:
    Leblanc
    I guess it is CvEventInterface.py and everything flows from there through the imports of your given event manager module?
     
  7. lfgr

    lfgr King

    Joined:
    Feb 6, 2010
    Messages:
    820
    I recently added a new python file in python/entrypoints that is only called from the DLL, and that one works fine. Maybe a module gets loaded when it is referenced by a call in the DLL (or exe).

    Doesn't the BUG mechanism of registering event handlers via XML work for you?
     
  8. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,399
    Gender:
    Male
    Location:
    Leblanc
    From how I understand it, it doesn't. That's because what I'd like to do is this:

    Code:
    # Events.py
    from BugEventManager import g_eventManager
    
    def handler(event):
        def handler_decorator(func):
            g_eventManager.addEventHandler(event, func)
            return func
    
        return handler_decorator
    Code:
    # Handler.py
    from Events import handler
    
    @handler("BeginGameTurn")
    def function_that_is_called_every_turn(*args):
        # code here
    
    @handler("BeginGameTurn")
    def another_function_that_is_called_every_turn(*args):
        # code here
    
    # and so on
    Basically the idea is that you shouldn't have to think too hard about registering functions and delegating their calls between modules, and it's simplified to adding a decorator with the event type to be handled.

    But this makes every Handler.py module transitively import BugEventManager. So if I load it from BugEventManager, I get a circular dependency. For the same reason, BUG's event handler registry doesn't work for me either, since it is triggered from BugEventManager as well (via the PreGameStart event, iirc).

    But you're right, EntryPoints is exactly where everything originates, containing all the Python files being called from the DLL.
     
  9. lfgr

    lfgr King

    Joined:
    Feb 6, 2010
    Messages:
    820
    You could import Handler.py at the end of BugEventManager.BugEventManager.__init__(). That way g_eventManager should be already created when Handler.py is loaded. But that's maybe not the most robust construction.

    Just to make sure I understand correctly, you want to avoid the following config file (untested), because you don't want to register every handler function in XML, and use decorators instead?
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <mod id="Handler" module="Handler" [...] >
       <event type="BeginGameTurn" function="function_that_is_called_every_turn"/>
       <event type="BeginGameTurn" function="another_function_that_is_called_every_turn"/>
    </mod>
    
     
    Leoreth likes this.
  10. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,399
    Gender:
    Male
    Location:
    Leblanc
    Yeah, I don't really like the declarative XML style that BUG seems to encourage.
     
  11. Dancing Hoskuld

    Dancing Hoskuld Deity

    Joined:
    Jul 5, 2004
    Messages:
    23,539
    Gender:
    Male
    Location:
    Canberra, Australia
    If you are using the BUG modular python stuff then don't you define it in BUG's config/init.xml? That is how I have set it up before. Of course I don't modify the dll at all. I just do python and xml mods.

    This way BUG handles all the integration stuff.
     
  12. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,399
    Gender:
    Male
    Location:
    Leblanc
    I'm not really using it. When I merged BUG and RFC code many years back, I didn't really want to refactor the entire existing RFC codebase, which heavily relies on event triggered logic. Also, I don't think I really understood that's how it was supposed to work back then, and I just wanted to make BUG work. RFC had its own huge event handler module hat implemented all the handler and then fanned out function calls to all the other modules. I am currently making the effort of refactoring all of that so each module does decentralised event handling. However, now that I am actually making the effort of rewriting the code I don't think BUG's way is the right thing to do either. I don't want to have to add each function/method into an XML config file and create a dependency that way that is neither readily apparent nor easy to refactor when I make code changes later on (for example, I run mass search/replace on Assets/Python, where function names in config files would not be found). A decorator is placed right at the function signature and makes it a) obvious that this is an event handler function and b) automatically respects renaming/deleting.
     
  13. topsecret

    topsecret Believer

    Joined:
    Feb 11, 2010
    Messages:
    5,615
    Gender:
    Male
    Location:
    At the Foot of the Cross
    So I've added some units that can be attached like Great Generals, but when one earns a Great General, sometimes you get the other units instead. Does anyone know where to find the code for this so I can just hardcode it to prevent it from happening?
     
  14. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,934
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Is it possible to when building a wonder than play not a specific wonder movie but one randomly from a certain list? Like units play random sounds when selected, given orders, etc.
     
  15. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,934
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Anyone knows a good model that could work as a Suburb improvement (upgrade from Town).

    I tried to copy-paste things from Town but the results are these:
    Spoiler :
    Ancient era
    upload_2020-5-15_11-8-58.png

    Modern era
    upload_2020-5-15_11-10-56.png

    As seen in the above pictures stays as a humble ancient cottage(?) :(
     
  16. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,399
    Gender:
    Male
    Location:
    Leblanc
    I can't help you because PlotLSystem is still a mystery to me, but are those screenshots from AND? Vanilla Civ and most mods handle modern cottage/city fluff buildings very awkwardly, where all buildings are suddenly skyscrapers even in the smallest cottage and as if all older buildings had suddenly disappeared. I always thought it would help realism and regional flavour to keep old building art around more even in later eras, and this seems to do that. I would love to be able to adapt some of that work.
     
  17. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,934
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Yes, my modmod is based on AND2.
     
    Leoreth likes this.
  18. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,934
    Gender:
    Male
    Location:
    In a constant brainstorm...
    It clearly works in C2C upload_2020-5-15_13-15-0.png but I don't understand the trick :confused:
     
  19. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,934
    Gender:
    Male
    Location:
    In a constant brainstorm...
    Here's my CIV4PlotLSystem file, maybe I miss something obvious.
     

    Attached Files:

  20. Vokarya

    Vokarya Deity

    Joined:
    Mar 25, 2011
    Messages:
    6,175
    I don't see anything wrong there, but is your <bUseLSystem> tag set to 1 in the CIV4ImprovementInfos.xml file? I think that's required to use the PlotLSystem.
     

Share This Page