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

I posted the new version in the beta testing thread. Refer to the change log and to the updated documentation for more information.

Note that 1. you need to get RFC Epic/Marathon v1.21 and 2. you're no longer required to manually reload Triggers when you save the Scenario.py file. :goodjob:

edit: Also, you shouldn't be using any Custom module unless it contains a method not included in the current PyScenario version. Because those are prototypes and might contain errors or cause other issues.
 
Code:
Trigger().player(7).check(1,0).fired("Celticcrusade").once().target((59,43),(62,45)).valid(-1,1,0,1,-1,0,1).units(-1,29,2).XP(3,5).promotions(0,6).AI("UNITAI_CITY_DEFENSE").message(Firstlegion).popup()
I wanted this Trigger (exactly valid() method) to spawn units in Roman city but it spawns units in random tiles of the area. Why?

Code:
Trigger("Roman Civics").player(7).date(tBirth(iRome)).civics(1,-1,1)
Is Trigger above correct? I don't have to define things like tBirth or import any additional files?

[EDIT]: Yeah, I forgot about the reason I posted here: could you make a global settings to find civ's capital?
 
I wanted this Trigger (exactly valid() method) to spawn units in Roman city but it spawns units in random tiles of the area. Why?
This is actually one of the new additions (from v2.0). If you're gonna spawn units in cities with a Plot List you need to enable the bGarrison setting. This was my fix for getting rid of the garrison() method. :p

Is Trigger above correct? I don't have to define things like tBirth or import any additional files?
No need to import Consts, because you should be importing the whole PyScenario module with the new setup. And Consts is already imported into PyScenario.py - so the references will carry over to Scenario.py also.

[EDIT]: Yeah, I forgot about the reason I posted here: could you make a global settings to find civ's capital?
You request, I deliver. What would the method be called and what setting do you need?

Another way of doing this would be to simply have some select methods pick the capital city tile as the default tile - if no map target is defined anywhere - but if a Target Player is present. Which methods would need this feature, you think? (I'm thinking units() - what else?)

edit: This is actually the easiest thing imaginable to implement. If you were programming Python instead of using PyScenario all you'd need is this:
Code:
pPlot = pPlayer.getCapitalCity().plot()
So I can basically add this anywhere needed in PyScenario. Or I could build a new method around it, but I'm not convinced that we need one. Do we?
 
capital() ?
Another way of doing this would be to simply have some select methods pick the capital city tile as the default tile - if no map target is defined anywhere - but if a Target Player is present. Which methods would need this feature, you think? (I'm thinking units() - what else?)
Exactly :) units(), output(), etc.

No need to import Consts, because you should be importing the whole PyScenario module with the new setup. And Consts is already imported into PyScenario.py - so the references will carry over to Scenario.py also.

Code:
from PyScenario import *
import Consts as con

So should I delete second line? Why Roman civics trigger didn't work? Because Rome doesn't have Monarchy?
 
So should I delete second line?
Yeah, if you leave it you're actually replacing the iRome value with con.iRome.
Why Roman civics trigger didn't work? Because Rome doesn't have Monarchy?
Probably because the old import statement makes the script not recognize the constants tBirth and iRome. (The are still con.tBirth and con.iRome because of the "as con" part of the import statement.)

Fix the Consts import at try again!
 
Ok, included is a variant (prototype for a new) units() method. It spawns the units in the capital if no other map target is defined.
Code:
from Custom import *
Trigger.units = units
What other methods would this need to be included?
 

Attachments

  • Custom_capital.zip
    1.9 KB · Views: 76
Easier for me, but perhaps not for the scenario maker...

But honestly the only work intensive part is to test these changes... :p
 
What about if you use the find() method without any arguments/settings? Then it could fetch the capital instead of any named city?

edit: No that isn't technically possible to implement (without a rewrite - even more testing). It would have to be the found() method, but I don't think that is very intuitive.
 
Code:
Trigger("Roman Civics").player(7).date(tBirth(iRome)).civics(1,-1,1)

Doesn't work.

Code:
Trigger("Roman Civics").player(7).date([B]-760[/B]).civics(1,-1,[B]11[/B])

Does. still, have no idea why first version is not working (beside having HR as Labor. Which works, just is a bit odd).
 
I tested it myself and soon realized this is a classic with Python. :D

You have to use brackets when indexing a data structure. Because using parenthesis will prompt the interpreter to call on the data structure as a function, which causes an exception.

If you (re-)enable bDisplayDebugMessages in PyScenario.py you will once again be getting the exceptions on initialization. :p

So what you do is this:
Code:
Trigger("Roman Civics").player(7).date(tBirth[iRome]).civics(1,-1,1)
This is far more programming that PyScenario was ever meant to be, however. So anyone else reading this can simply keep moving. Nothing here to see. :D
 
So, LuKo, when are you going to pick up proper Python programming? :D
 
Someday :p Learning programming takes a lot of time. As long I don't have to (simple changing numbers, copying code, etc. is enough to achieve most of my aims) I don't try to do anything more. I almost read "How to Think Like a Computer Scientist" but now I don't remember almost anything :p So for sure not when I'm in home (and probably it depends on who I'll be living in dormitory with).
 
http://forums.civfanatics.com/showthread.php?t=361003

I'd like PyScenario to allow some of my ideas posted there :p Yeah, it's massive and I know you are busy but I have time :p Any trigger that can become handy is welcomed (you know better what's possible to do). Some things to start with: modification to tech(), that check if player is the first to invent technology, goldenage() which triggers golden age :p and deflag() which makes fired label look like unfired. Good luck :p
 
I'd like PyScenario to allow some of my ideas posted there :p
You need to be more specific. Like this:
Some things to start with: modification to tech(), that check if player is the first to invent technology, goldenage() which triggers golden age :p and deflag() which makes fired label look like unfired.
Are you going to use PyScenario for mod-modding again? :rolleyes: You really need to hack into the Python code to change things - PyScenario can pretty much only add events at historical dates.

Regarding the actual requests, I wonder if CyGame.countKnownTechNumTeams() could be used to register if the Tech has been discovered before? (A return value of 1 onTechAquired would mean that it was the first time around for that particular Tech.)
 
Rhye used onTechAcquired() and checked if iPlayer was right. If no, a dedicated variable was set to -1 (someone else was first), if yes and it's not -1 yet, it's set to 1 (you are first).
 
Are you going to use PyScenario for mod-modding again? You really need to hack into the Python code to change things - PyScenario can pretty much only add events at historical dates.

Again? I've never stopped XD It would take at least month for me to know the basics and another two months to redo what I created with PyScenario. That's 3 month of no progress :/
 
You mean stored values? I'll try just about anything before I implement a global index on each and every Tech in the game/mod.
 
Top Bottom