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

Introducing: PyScenario - easy-to-use scenario event scripting for RFC

Discussion in 'Rhye's and Fall Modmods' started by Baldyr, May 16, 2010.

  1. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    This is interesting. Looking at Rhye's code (CityNameManager) I can see that there are three conditions for the rename to fire: 1. Viking receive any Tech, 2. the Viking are in the Renaissance era, and 3. the Viking own a city called "Nidaros".

    The PyScenario Condition Trigger(11).tech(eEra=3) is also checked whenever the Vikings receive any Tech, but it is the Era that the Tech belongs to that determines whether or not the Action(s) will be fired. This is probably why Nidaros became Trondheim and Birka didn't become Stockholm.

    Without testing it myself (yet) I would guess that the Trigger had already fired before Birka was founded/spawned (because the Vikings somehow received a Renaissance Tech). But then again - it should fire each time the Conditions are met... (I'll have to revisit the actual code.)

    I'd say its the same issue as with the Vikings. Could it be that trading Techs don't count as "Tech Acquired" according to the game?

    Thank you for testing and I will be doing some debugging of my own using your script as soon as I get the time. Hopefully tomorrow night. :king:
     
  2. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Regarding the city naming issues, I believe I found the bug and I commented on it in the beta-test thread.
     
  3. killerkebab

    killerkebab Prince

    Joined:
    Jun 25, 2009
    Messages:
    571
    I'm in the mid 18th century now and time between turns seems to be increasing very fast. Shouldn't lag affect less as time goes on, as triggers get discarded?
     
  4. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    I replied in the beta-testing thread. Lets try to keep the testing issues in there, because otherwise this thread will be cluttered down with bug reports and such. :p
     
  5. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    I'm happy to report that I've tracked down the source for any lag and that it has been successfully taken care of! :goodjob: As I said in the testing thread: expect the next update to be free of any lag issues. :king:
     
  6. civ_king

    civ_king Deus Caritas Est

    Joined:
    Mar 9, 2006
    Messages:
    16,368
    is it possible to make all cottage/hamlet/villages give +1:food: and towns give +2:food: only in Asia? Because I want to mimic large population in Asia.
     
  7. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    This would fall beyond the scope of PyScenario, but practically anything is possible - if you know how to code it yourself.

    You could probably add :food: to any city with CivIV Python, so what you wanna do is find a way to loop through all the cities in that area (or just all Indian and Chinese cities, period?) and lookup whether or not they are working any of the improvements you mentioned. And if they are, add food accordingly.

    The trick, of course, is to make your code as efficient as possible so you're not adding to the lag... :p

    Another idea could be to simply add :food: to all cities of select Civs on every turn. This will make their cities grow and also make them not starve before the shortage gets out of hand totally.

    What about increasing the :food: output of Rice? If that resource is only found in the desired areas this would have an effect on population change. You can change this easily in the XML.
     
  8. civ_king

    civ_king Deus Caritas Est

    Joined:
    Mar 9, 2006
    Messages:
    16,368
    I also wanted it to apply food to other civs in that area, so Britain's Indian cities would get extra food too,

    could I make a building called "Slums" that would be added to all Asian (and now that I think about it South America too) every 10 turns and check on city trade/found/conquest?

    would this slow the game down too much?
     
  9. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Yes, of course. Then it would simply be a matter of finding all cities inside a defined area. Not too hard to do.

    Do you mean like a UP? That cities in some areas get a free building? What would that building do? (If you simply wanna add food that part can be done in the XML.)

    It would depend, I guess. Testing would be required.

    If you're interested in testing PyScenario I could probably make some methods for you to test out. Like a food() method for adding food to a target city. And by defining a map area (like Asia) you could use a PyScenario script to add food to all cities inside this area. On every turn, on every other turn, at a random interval, or whatever you like.

    And if you manage to add a building to RFC (not as easy as it would seem, by the way), it would be easy to add that building in any city with PyScenario (it would involve using the buildings() method)...
     
  10. civ_king

    civ_king Deus Caritas Est

    Joined:
    Mar 9, 2006
    Messages:
    16,368
    Slums: all cottage/hamlet/villages give +1:food: and towns give +2:food:

    Slums would be added to all cities in the pre-defined ares (I want them to be Brazil, India, SE Asia and China, but wouldn't be that hard?), I want this to be done through town line because pillaging towns=razing slums
     
  11. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Ok, start by figuring out how to add the Slums building, then. I can't help you with that one, since I'm yet to add a completely new building to RFC myself. Where to get the graphics? (Or would it exist in name only? Like the Triumph Arch national wonder.)

    To get the desired effect - Cottages>Towns give extra :food: - there would be two paths you can take. (And I don't think you can achieve this through editing the XML entries for the improvements.)

    The easier would probably be a Python mod that checks all cities and grants the :food: every turn if the Slums building is present and if the improvements in question are there and are worked. This would not be reflected in the city screen - at all - though, but the :food: would just magically appear in between turns. Very confusing for the human player, I'm sure... :rolleyes:

    The more advanced method would involve C++ code and I wouldn't even know where to start, I'm afraid. But it might be possible to override the XML settings for the improvements (extra :food: output) and make the actual improvements yield more :food: - only in cities with the Slums building.

    Only a small part of this could be achieved by utilizing the PyScenario application, why I guess you probably should start a new thread for this project...
     
  12. civ_king

    civ_king Deus Caritas Est

    Joined:
    Mar 9, 2006
    Messages:
    16,368
    what about the building getting +1 food per cottage/hamlet/village? and +2 per town? not built into the improvements
     
  13. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Yeah, as I said - it should be possible to add some Python code that checks cities and grants :food: based on the presence of a specific building in cities what are working certain improvements. I can help you with this part - whether you wanna add some code into the Event Handler directly - or whether I build in support for this in PyScenario.

    But you could still start by adding the building itself to the mod. (The easiest way would be to simply replace a building or wonder that you don't consider essential to the mod. But then there is the issue with the graphics... Someone ought to be able to help you though.)
     
  14. civ_king

    civ_king Deus Caritas Est

    Joined:
    Mar 9, 2006
    Messages:
    16,368
    It does not need graphics and needs to be spy-proof
     
  15. Brew

    Brew Warlord

    Joined:
    Feb 7, 2010
    Messages:
    136
    Is there somewhere I can get a copy of the map with the coordinates displayed (not necessarily each individual tile, just the axes)? I can't imagine all you modders count tiles every time you want to change a plot. This would really help me to start playing around with the event scripter. Thanks!
     
  16. Brew

    Brew Warlord

    Joined:
    Feb 7, 2010
    Messages:
    136
    Nevermind about the tile coordinates; I should finish reading the instructions before posting questions eh?
     
  17. civ_king

    civ_king Deus Caritas Est

    Joined:
    Mar 9, 2006
    Messages:
    16,368
    When I'm messing with the plots I have Civ in windowed mode, go into world builder and use the sign tool on the British dye (easiest to remember location of) and go in each direction labeling every five tiles or so
     
  18. killerkebab

    killerkebab Prince

    Joined:
    Jun 25, 2009
    Messages:
    571
    Tiles begin at (1,1) in the top left corner of the map.

    To find out which tiles are where, enable cheat mode in Civ4.ini - there are numerous guides on how to do this.

    Once that is done, simply hover over any tile and hold the shift key - in the bottom left of the screen, the game will inform you which tile you are looking at.
     
  19. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    In the name of not adding to the confusion (but thanks for trying to help! :goodjob:), here's what the tutorial says:
    I believe that the map tiles are actually numbered from bottom left (0,0) to upper right (123,67).
     
  20. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    A major update can be downloaded from the beta-testing thread. :goodjob:

    PyScenario should now be lag free - or as lag free it can get while still saving Triggers along with the rest of the game session. (At least this will no longer effect autoplay...)

    See the change log for details. (Killerkebab: You could try out the new stability() method if you like. :king:)
     

Share This Page