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
    Did anyone ever test this out? Because I would like to add it to the next release.
     
  2. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Embryodead releases a new version of RFC: Epic/Marathon today and I'll get to working on a new version of PyScenario accordingly.

    Features in the next update will be dynamic detection of mod folder (so that you can use PyScenario with your own mod-mod of RFCM) and hopefully a fully functional version of the civilization() method now only found in the Dynamic Byzantium mod-mod. (Its used to change the civilization attribute of a player in mid game. :eek2:) And if no one can come up with any issues with the tentatively released rebirth() method (granting Golden Ages) it will also be included.

    Any other requests will be considered also.
     
  3. G-Max

    G-Max Deity

    Joined:
    May 20, 2006
    Messages:
    2,556
    Ugh. Everyone in my house gets evicted because the new owners want to remodel, and in the 3 months that I'm gone, I forget everything I knew about PyScenario... :sad:

    Code:
    Trigger("Stonehenge").date(-3000).player(31).city(51,53,"Stonehenge",1).buildings(118)
    So, like... Does PyScenario know that Stonehenge goes in the city that this trigger spawns? I'm ready to get back on the horse.
     
  4. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Yeah, for sure.

    I think you might wanna read through the API once more before going forward.
     
  5. G-Max

    G-Max Deity

    Joined:
    May 20, 2006
    Messages:
    2,556
    Good news: I successfully got the very beginnings of my script working.

    Bad news: in order to do it, Stonehenge has to be built in 2970 BC, not 3000 BC. Anything that is set to happen on a certain date will only happen when the calendar turns to that date from whatever date comes before it. It's thus impossible to trigger anything to happen in 3000 BC, as far as I can tell.

    I recommend fixing this.

    Anyway, on to the rest of the Wonders... and the drudgery of repeating the necessary research that's on my currently non-functioning hard drive.

    EDIT: never mind, I found the mythical .startup method

    EDIT #2: Okay, I made a Hanging Gardens trigger and tested it. The first time, Babylon collapsed before the event could trigger. The second time seemed to work. The third time, Persians captured the city before the event could trigger. The fourth time, China built the Gardens before the event could trigger. I have seriously never seen events 1, 3, or 4 in a regular game. This called for more test runs. So I kept going in Game 4, and guess what? A SECOND Hanging Gardens was built in Babylon right on schedule. After several more runs that were rather boring, I decided to shake things up. I destroyed Babylon. But regardless, at 595 BC, right on schedule... "The Hanging Gardens has been built in a far away land". This message really shouldn't pop up when there's no city in which to put a building. Then I tried out various collapsing and flipping triggers, and I was able to confirm that yes, the trigger will only fire if the Babylonians are still around. However, if someone else controls Babylon but the Babylonians are still alive, the Gardens will still get built. I don't even want to bother testing the "AI only" part of it. Here's my code; tell me what I'm doing wrong:

    Code:
    Trigger("GardenCheck").built(121)
    Trigger("Gardenspawn").date(-600).fired("GardenCheck",bFired=False).check(bHuman=False,bDead=False,ePlayer=3).owned(tCoords=(76,40),eOwner=None,bVassals=False).buildings(121)
     
  6. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    I guess that you should define the global setting Target Player with the player() method. (Look it up in the API section 2.3 - its one of the core methods for building Triggers.)

    Or am I missing what you're trying to achieve?

    And perhaps it should never be possible to spawn a second version of any World Wonder? :rolleyes:
     
  7. G-Max

    G-Max Deity

    Joined:
    May 20, 2006
    Messages:
    2,556
    I must have missed some fine print somewhere. Oh, here it is:

    See, this is why I keep saying "I hate you". I spent four goddamn hours testing that trigger, trying to figure out what was wrong with it, only to find out that you're breaking your own rules...
     
  8. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    This rule doesn't prevent certain methods from having local settings for player and map targets.

    And drop the attitude. You simply missed some important documentation and I'm giving you free support here. Lighten up!

    If you have actual suggestions on how to improve the documentation, then I'm all ear.
     
  9. G-Max

    G-Max Deity

    Joined:
    May 20, 2006
    Messages:
    2,556
    You were remarkably opposed to the idea when I asked for such enhancements to the program...

    Sound familiar?

    Okay. Replace this:

    With something like this:

     
  10. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    :lol: Good one! :goodjob:
     
  11. G-Max

    G-Max Deity

    Joined:
    May 20, 2006
    Messages:
    2,556
    Yeah, not knowing how to use PyScenario well means that I can suggest all sorts of helpful "Allergy Warning: these peanuts may contain traces of nuts" suggestions for the documentation :lol:

    Anyway, your advice should solve the problem with the Gardens spawning when someone else controls Babylon. But how do we solve the problem of .fired("GardenCheck",bFired=False) not working?
     
  12. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    What now? :confused:

    I guess I should make an addition to the buildings() method that doesn't allow for World Wonders to be created if they already exist. (Have existed?) Makes sense?
     
  13. G-Max

    G-Max Deity

    Joined:
    May 20, 2006
    Messages:
    2,556
    This:

    It's okay; I don't blame you for not remembering.

    Well, it would be easier to fix the trigger than fix the program. Also, for whatever reason, some people might WANT to spawn multiple copies of the same Wonder. Maybe you could make that an optional parameter... like .building(121,bAlready=True)?

    And you should definitely block the event from going off if no city is there in which to put the building :)

    EDIT: Well I tried this in order to save a few CPU cycles...

    Code:
    Trigger("GardenCheck").date(-600).once().built(121)
    Trigger("Gardenspawn").date(-600).fired("GardenCheck",bFired=False).player(ePlayer=3).check(bHuman=False,bDead=False).owned(tCoords=(76,40)).buildings(121)
    ...and it's suffering the same problem. I could roll back the GardenCheck date to 610, but that carries the possibility that someone could build the Gardens on the turn before the Babylonians are supposed to, and we'd still get two of them.
     
  14. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Lets just say that I'm finding this very confusing.

    Well, I don't see any good reason to allow multiple World Wonders. Because it would make more sense to make them National Wonders instead. But you're suggestion has merit nonetheless and is under consideration.

    What exactly happens when the "event is going off" when "no city is there"? Because it shouldn't be possible to add buildings to non-city map tiles. What could possibly happen?

    And the problem would be that the "GardenCheck" Trigger isn't being fired? Because it doesn't register as fired with the fired() method in the "GardenSpawn" Trigger?

    I'm getting the feeling that what you need is a method for checking whether or not there is a city on a given tile. I can't seem to be able to find anything for this in the current API, so why not request one such method to your specifications? Or perhaps could one of the existing methods be augmented somehow?

    It was a while since I worked on PyScenario actually and its all coming back to me now. G-Max, I now realize how much you have contributed to the last few versions and that I should probably thank you for you this. If you only had been on-board from the get-go this application might have been better than it is currently. (I might make a new version from the ground-up someday, but I doubt anyone else would be around modding RFC in such a distant future.)
     
  15. G-Max

    G-Max Deity

    Joined:
    May 20, 2006
    Messages:
    2,556
    I get a message saying "X has been built in a far away land", but the Wonder doesn't get built. It's more of a nuisance than a functional problem.

    Well, I've traced the problem to either .built not properly working or .fired not properly working. I used the following code...

    Code:
    Trigger("GardenCheck").built(121)
    Trigger("KillChina").fired("GardenCheck").player(ePlayer=2).collapse(bFragment=False)
    ...fired up a game as Japan, and waited for China to collapse. They never did. Babylon built the Gardens and China kept going as if nothing had happened.

    So it looks like you have some work to do, cute lady ;)

    I was going to suggest that, but it was a low priority (for my project anyway). I figured that if there was a city on the tile, then great, and if not, then nothing would happen anyway.

    Thanks :D But the folks who you should really thank are the guys at Blizzard who made Starcraft. I'm used to seeing/making stuff like "If player 1 brings a Battlecruiser to Location X and player 2 brings 5 Archons to Location Y, then spawn 200 Zerglings for Player 3 at location Z, set players 4 and 5 to fighting each other, and move all flags on the map to wherever Kerrigan is". Naturally, when I try to do even simple (in my opinion) things in Pyscenario, I learn that they're still not simple enough, and start going nuts. I'll probably end up being the most strenuous tester you'll ever have...

    "If the Greeks control a city at 65,40 and at least 5 Immortals have been killed by Phalanxes between 68,43 and 70,45 then play audio clip ThisIsSparta and spawn Xerxes at..."
     
  16. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Oh, that. I have no idea how that is even possible... I guess I need to add a check towards any active cities on the target tile, then.

    So your diagnosis is that the built() method isn't registering the Hanging Gardens, then? I suppose I should do more testing on this... :p

    Yeah, but what if you added a text-message heralding some historical event with the message() method? That would still fire even if there was no city present...

    This is actually my own experience from working with PyScenario (scripting events for the sample scenarios I've made) also. Even the simplest of tasks tend to become very complicated.

    I think that the problem is that PyScenario is simply a set of constrains on what the CivIV Python API can be used for. While it should be easier to use, its mostly just restricted. And this is the cause of all the headache. I basically think everyone should just learn Python and then they'd be able to do pretty much anything they want to.
     
  17. G-Max

    G-Max Deity

    Joined:
    May 20, 2006
    Messages:
    2,556
    No, it's the .fired method. I just ran a test with more streamlined code to isolate .built from .fired...

    Code:
    Trigger("GardenCheck").built(121).player(ePlayer=2).collapse(bFragment=False)
    ...started as the Chinese, gave myself mathematics and a Great Engineer, and instant suicide.

    The alternative possibility is that .built only works correctly when a Target Player is set.

    EDIT: Damn, I'm good. I just ran my NINE THOUSANDTH test in the past 24 hours with the following code...

    Code:
    Trigger("GardenCheck").built(121).player(ePlayer=3)
    Trigger("KillChina").fired("GardenCheck").player(ePlayer=2).collapse(bFragment=False)
    Trigger("Gardenspawn").date(-2000).fired("GardenCheck",bFired=False).player(ePlayer=3).check(bHuman=False,bDead=False).owned(tCoords=(76,40)).buildings(121)
    ...then started up the game as Greece. China was dead. .fired works fine; it's .built that doesn't work as intended unless given a target player.

    You're welcome. Now, if you'll excuse me... I'm sick of Civ IV for now. I'm gonna see if Tron Legacy has been pirated yet.
     
  18. G-Max

    G-Max Deity

    Joined:
    May 20, 2006
    Messages:
    2,556
    Baldyr passed me a note that the teacher wants me to read in front of the class:
    Moderator Action: Publishing private messages is not allowed.

     
  19. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Am I imagining things or did this guy just post a private message? :eek:

    As time is scarce and I have tons of other projects and also real life duties to attend to, any further development of PyScenario is in doubt. I of course realize that interest in the application has also plummeted due to the release of CiV.

    But if G-Max is what I'm stuck with as far as beta-testers goes, then its not even worth the effort. I'm in no way trying to diminish his contributions or denying his talent as a tester or game designer. I'm just not gonna waste my breath on him anymore.

    The promised PyScenario update might still make an appearance before the new year - since I should be able to get some hours worth of work done on it over the holidays - but right now its firmly at the bottom of my priorities list.
     
  20. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    34,304
    Gender:
    Male
    Location:
    Leblanc
    If I were you, I'd ask him to remove this or report that post ...
     

Share This Page