• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

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

I don't even know how to reply to anything like that. Perhaps: Why don't you do it yourself then?

Now, stop wasting space in this info thread, please. I'm done with you.
 
I can do the conversion for you, just send me the script. :)
 
One key thing to update in your scripts is the import statement(s):
Code:
from PyScenario import *
from Consts import *
This also means that you can (well, have to) drop the con. prefix for any constants you're fetching from Consts.py.
 
I'm working on methods for re-spawning Civs. So first you use collapse() to kill it off - if it isn't dead already. Then you use a new reset() method for canceling deals and and setting default stored values (stability et cetera). Then you can revive the Civ by spawning any unit for it with units().

One additional option will - hopefully - be available: The civilization() method that changes the civilization type of the target player. This means that we can first set the German player to Holy Roman Empire with the civilization() method with startup(). Then, when the German Civ is due to respawn as the unified German Empire the civilization type will be changed back with civilization().

This could also be done with Celtia - it is collapsed right before the Byzantine Empire is born. Then the civilization type is changed and the actual unit that revives the player is spawned.

Thoughts, ideas?
 
I'm a bit confused about the interaction between built and buildings. I want to check the entire map for a Hanging Gardens, and if none are found, place one at 76,40 (Babylon's coordinates). However, the buildings action requires a Target Tile or Plot List, and if I include one of those, then built will only check those tiles!

How do I shot web?

I guess that what I'm saying is that it would be nice if these methods came with their own tCoords parameters.
 
Say you want this to happen in 500BC:

Code:
Trigger("Hanging Gardens Check").date(-500).built(121)
Trigger("Hanging Gardens Spawn").date(-500).fired("Hanging Gardens Check",bFired=False).target(76,40).buildings(121)

Something like this?
 
I'd have to split it into two triggers? Lame. I was hoping to do it in a single trigger, like this...

Trigger().date(-600).check(ePlayer=3).owned(tCoords=76,40,eOwner=3).built(eBuilding=BUILDING_HANGING_GARDEN,iNum=0).buildings(BUILDING_HANGING_GARDEN)

...but with something specifying where to build the Gardens.
 
The problem with a one Trigger approach is the both the Target Player and the Target Tile are global settings, so they apply to both the built() and buildings() methods. So you basically can't look for a building/wonder in any tile owned by any player with a Trigger with such global settings.

A couple of things: The tCoords value should be expressed as a "tuple" so you wrap the coordinates into a pair of parenthesis, like: "(76,40)". Also, the buildings should be expressed as integer values, not the XML tag. If you wanna use he actual building type, then you need to do the entire "BuildingTypes.BUILDING_HANGING_GARDEN". You can alternatively use Rhye's constant from Consts.py: iHangingGarden but you could also could also define your own variable and use that instead:
Code:
eHangingGarden = eIndex("building", "Hanging Garden")
 
If you wanna use he actual building type, then you need to do the entire "BuildingTypes.BUILDING_HANGING_GARDEN". You can alternatively use Rhye's constant from Consts.py: iHangingGarden but you could also could also define your own variable and use that instead:
Code:
eHangingGarden = eIndex("building", "Hanging Garden")

7d2134001b6c42b19291c8e62106cacc.jpg

1250122812118.jpg


LOL. So, my script should look like this?

Code:
Trigger("GardenTrigger").date(-600).check(ePlayer=3).owned(tCoords=(76,40),eOwner=3).built(eBuilding=121,iNum=0)
Trigger("GardenSpawn").fired("GardenTrigger").target(76,40).buildings(121)
 
So, my script should look like this?
Almost. The first Trigger wont work as intended because the Trigger will be looking for a Hanging Gardens in Babylon - not anywhere on the map.

And this won't work because the method will then look for zero or above instances of the building:
Code:
Trigger("GardenTrigger").date(-600).check(ePlayer=3).owned(tCoords=(76,40),eOwner =3).built(eBuilding=121,[COLOR="Red"]iNum=0[/COLOR])
(You could add the operator() method with a OperatorTypes.OPERATOR_EQUAL_TO setting however to salvage it though. Look in the API for details.)

This should work (but you might wanna test it instead of just taking my word for it):
Code:
Trigger("Garden built?").date(-600).built(121)
Trigger("Spawn Garden").fired("Garden built?",[COLOR="Red"]False[/COLOR]).player(3).check().date(-600).target(76,40).owned().buildings(121)
Or perhaps:
Code:
Trigger("Garden built?").date(-600).built(121,0)[COLOR="Red"].operator(2)[/COLOR]
Trigger("Spawn Garden").fired("Garden built?").player(3).check().target(76,40).owned().buildings(121)
edit: I changed my own code - I messed the first attempt up. :rolleyes:
 
Almost. The first Trigger wont work as intended because the Trigger will be looking for a Hanging Gardens in Babylon - not anywhere on the map.

Why? I thought that tCoords=(76,40) would apply only to the owned condition. I included no global target tile in the first trigger...

And this won't work because the method will then look for zero or above instances of the building:

So we're not going by "equals means equals, dammit!" logic, then? Got it.

Hey, I know that programming changes are easier to suggest and harder to make than simply learning how to use PyScenario correctly, but would you be at all offended if I humbly suggested some enhancements to your wonderful tool? For example, adding ">" and "<" options to certain functions in addition to the classic "="? In return, you may humbly edit the hell out of my script for balance or playability reasons.

This should work (but you might wanna test it instead of just taking my word for it):
Code:
Trigger("Garden built?").built(121)
Trigger("Spawn Garden").fired("Garden built?",[COLOR="Red"]False[/COLOR]).player(3).check().date(-600).target(76,40).owned().buildings(121)
Or perhaps:
Code:
Trigger("Garden built?").built(121,0)[COLOR="Red"].operator(2)[/COLOR]
Trigger("Spawn Garden").fired("Garden built?").player(3).check().date(-600).target(76,40).owned().buildings(121)

Domo arigato. I like the first one, because I'll never remember what .operator(2) does.
 
Why? I thought that tCoords=(76,40) would apply only to the built condition. I included no global target tile in the first trigger...
The way I originally designed PyScenario was that there are only global tile targets. So if you define a target tile anywhere in a Trigger it applies to all methods. Like it or not, but this is how it works...

Hey, I know that programming changes are easier to suggest and harder to make than simply learning how to use PyScenario correctly, but would you be at all offended if I humbly suggested some enhancements to your wonderful tool? For example, adding ">" and "<" options to certain functions in addition to the classic "="?
PyScenario is really just Python coding, and your suggestion simply doesn't make any sense in Python. Sorry.
Spoiler :
By the way, "=" is used for assigning values in Python. "==" is the operator for "equals to".

Domo arigato. I like the first one, because I'll never remember what .operator(2) does.
I actually messed my own code up, so you might wanna look at the updated version. And test it, as I might have overlooked something... :rolleyes:
 
Just stop with the whining and learn Python instead. Its a high-level programming language that lets you do all the logic you'd ever wanna do.

PyScenario is just my way of fooling scenario makers who think programming is hard to use Python. ;)
 
I'm sorry, but I just can't be arsed to learn a whole new set of tools and a whole computer language every time I want to mod a game. Just for my digital video editing hobby, I had to learn how to use Smartripper, DVD2AVI, AVIsynth, Adobe Premiere Pro, Virtualdub, TMPGEnc, Windows Media Encoder, and a litany of plugins and codecs, plus some basic knowledge of interlacing, colorspaces, etc. When I had my own website, I didn't pay for hosting or go with something lame like Geocities; no, I got a static IP address, learned how to use Apache, and hosted my website from my own apartment on my own computer (Nigouki, may she rest in peace). For Diablo II, I had to use MPQview and D2Excel before even getting to look at the data, and then I had to try to figure out what it all meant and how it worked. C&C 3: Tiberium Wars required downloading a dozen things and creating a hundred subfolders before I could even touch the data, and then I had to learn a wee bit of XML before I knew what the hell I was doing. In the middle of all this, I've been trying to find the time to learn Japanese. So the fact that I'm even bothering with PyScenario... ugh. I'm learning so much that I'm starting to forget the differences between British and American spellings of words. Please, don't criticize.

Anyway, I'd like to know whether I'm using the iX and iY parameters in the .city method correctly:

Code:
Trigger("Stonehenge").date(-3000).player(31).target(51,53).valid().city(51,53,"Stonehenge",1).buildings(118)

?

EDIT: another question. Is there any way to check the presence or absence of a certain religion in a city? i.e., can I make the Hagia Sophia spawn in Byzantium/Constantinople only if Christianity is present there? Right now, the closest that I can do is make it spawn only if Christianity is the state religion of whoever owns the city:

Code:
Trigger("HagiaCheck").built(126)
Trigger("HagiaSpawn").date(537).fired("HagiaCheck",False).owned(68,45).check().faith(1).buildings(126)
 
Your city parameters are correct. Also, you don't need to specifcy a target() trigger since you're specifying the city's location in the city() trigger :)

As for the Hagia Sofia, the best I can see from the triggers available is to check whether there exists a Christian temple in the city. It won't fire every time obviously, but it might be good enough for your purposes.
 
Your city parameters are correct. Also, you don't need to specifcy a target() trigger since you're specifying the city's location in the city() trigger :)

What city() trigger?
 
I'm sorry, but I just can't be arsed to learn a whole new set of tools and a whole computer language every time I want to mod a game.
I'm actually floored by the sheer determination and dedication you have for modding. :eek: Learning to program would probably be the easiest single skill you ever learned for this purpose. I'm just saying.

Anyway, I'd like to know whether I'm using the iX and iY parameters in the .city method correctly:
Yes. And killerkebab is right - you don't need to define a tile twice in the same Trigger:
Code:
Trigger("Stonehenge").date(-3000).player(31).target([COLOR="Red"]51,53[/COLOR]).valid().city([COLOR="Red"]51,53[/COLOR],"Stonehenge",1).buildings(118)
Other than that, you could just add the city/wonder to the 3000 BC scenario directly. (Edit the WBS file.) If you can't be bothered with it, you at the very least want it present on the first turn (before the game starts), right?
Code:
Trigger("Stonehenge")[COLOR="Red"].startup(bLateStart=False)[/COLOR].player(31).target([COLOR="Red"]51,53[/COLOR]).city([COLOR="Red"]51,53[/COLOR],"Stonehenge",1).buildings(118)
(I deleted the valid() Condition because there should be no reason why the tile isn't valid before the game starts.)
EDIT: another question. Is there any way to check the presence or absence of a certain religion in a city? i.e., can I make the Hagia Sophia spawn in Byzantium/Constantinople only if Christianity is present there? Right now, the closest that I can do is make it spawn only if Christianity is the state religion of whoever owns the city:
This is correct... It never dawned on me to check cities for religions present. I'll have to be get back to you on this. But otherwise you could also spread Christianity to the city with the same Trigger, which would probably make sense:
Code:
Trigger("HagiaCheck").built(126)
Trigger("HagiaSpawn").date(537).fired("HagiaCheck",False)[COLOR="Red"].target(68,45).owned()[/COLOR].check().faith(1).buildings(126)[COLOR="Red"].religions(1)[/COLOR]
Note that this will replace any other religions present in the city. If you wanna add Christianity to whatever is already present you need to do that with a separate Trigger and define the map target as a Plot List instead. See the API.

I also added the target() method for defining the Target Tile. Otherwise you would have had to put the coordinates inside a tuple: owned((68,45)) - this is just plain confusing so I'd recommend using the target() method instead in order to avoid simple mistakes.
 
Back
Top Bottom