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

Is it possible to make some kind of reloading triggers without clearing fired() and once() things?
No, unfortunately not.
 
Can I use pyscenario (if not, anything else?) to make an RFC mod from scratch? And if so how do I apply the py data to the custom map I made?
 
Baron03, no you can't. You need to learn proper Python for that. But thankfully its not very hard - see my signature below for some obvious entry points.
 
Where can I get info for like Russia is player(27) or China is player(2) ? And info for Market is buildings(59) ?

Thanks :)
 
Rhye stores all the constants in the Consts.py file. Everything that is BtS standards can also be found here.
 
LuKo, I'm not currently developing PyScenario due to not having a proper home. (I'm redecorating.) If you prompt me at a later date (like this summer or whatever) I would probably pick this PyScenario thing up once again, since there still is interest in the application.
 
I'm trying to add a functionality to my pyscenario but i can't understand very well how it works.
I want to add the prob(iProb) function that fires the trigger randomly with an iProb probability.

So i added the following code to Pyscenario.py

Code:
import random

        def prob(self, iProb):
                self.Conditions.appendEntry(CheckRandom(iProb))
                return self

class CheckRandom(Conditions):

        def __init__(self, iProb):
                self.prob = iProb
                self.notTurnTrigger = None

        def check(self, pContext):
                #pContext.debug(("CheckFired.check()", self.binding, self.fired), {})
                #if random.random()*100<self.iProb:
                return random.random()*100<self.iProb
                #else:
                        #return False

now...i don't get errors...but if i write
Code:
Trigger().player(iEgypt).date(-2990).check(True,False).message("ROFLCOPTER").popup(True).prob(100)
it never triggers :(
 
Did you ever try the interval() method with built-in random turn check?
interval( iInterval=1, bRandom=False, bScaling=True )
This Condition makes the Trigger fire at turn intervals by limiting the valid game turns to ones that are equally dividable with the iInterval setting. Note that its not possible to change which actual game turns are valid - only the interval. Also note that the iInterval setting refers to game turn on Normal game speed and that if the last setting is left unchanged (bScaling=True) the interval will change dynamically on other game speeds. (Its roughly 1,5 times the interval on Epic speed and 3 times on Marathon speed, but there will be some unforeseeable rounding issues.) This can however be prevented entirely by changing the setting to False - then the turn interval will be exactly the same on all game speeds.

The second setting (bRandom) can be set to a True value and then the condition will be fired at random intervals. The probability is basically one in the iInterval value on Normal speed. The random interval scales as above on other game speeds.
 
umm but i want it to fire with a certain probability in one specific turn/year...not to fire in a random interval of turns.
Can I do it with that method?
 
Try using both date() and interval(). My reasoning is that the first Condition is met only at the desired date, while the second has a random chance of that game turn being valid.

It was a while since I lastly looked at this stuff myself, so I'm trying to traceback my own thinking here. :D
 
Those are done in C++, while PyScenario is a Python module. PyScenario doens't ship with a new DLL file, and never will.

I might, however, make another scenario making tool in C++ one day. Not this year, though.
 
Okay..
will be looking forward to the C++ Scenario tool if one day you make it ;)

Some questions.
How do I spawn a independent city that mustn't belong to any AI before a coded turn?

Some requests.
Will you add some example how to flip a cities, in the front page? I'm a bit confused.
Please do teach me how to flip cities from AI to Player, AI to minor, Minor to AI, all vice versa :D

Big Thanks!
P.S : I'm having unknown error with the Google Talk installation.
 
How do I spawn a independent city that mustn't belong to any AI before a coded turn?
You mean that you need one Trigger for spawning the city, and then another one that automatically flips it back to a minor player if acquired by a major player?

Please do teach me how to flip cities from AI to Player, AI to minor, Minor to AI, all vice versa :D.
As with any PyScenario event you need to define a Trigger for it. Each Trigger has a Target Player and a Target Tile. For flipping cities you use the flip() method. From the API:
flip( name=None, eOwner=None, bMinorsOnly=True, bAIOnly=True, bSafe=True )
This Action hands over the reigns of a city to the Target Player. The default way of defining the city - and thereby the Target Tile - is to use the name setting (string). (To define a Target Tile - or a Plot List - are equally valid options.) Actually, if the name setting (string) is used in tandem with other map target definitions, then it will work as a built-in condition. (The city by that name has to be on the Target Tile or within the Plot List.) It is also possible to specify the prerequisite current owner of the city with the eOwner setting.

Only cities belonging to Minor Civs and controlled by the AI are, by default, subject to city flipping. These settings (bMinorsOnly and bAIOnly, respectively) can however be disabled (set to a False value).

Civs losing cities due to flips are by default safe from automatic collapse (bSafe=True), but only if the eOwner setting is also used (set to other value than None).
So flipping London to the English on AD 900 you would go:
Code:
Trigger("flip London").date(900).flip("London",iEngland)
There are additional parameters you could use; restricting the flip to minor players only or restricting the flip to AI players only, or to safeguard the current owner from collapse due to the flip. These are all enabled (True) by default, but can easily be disabled (False), like this:
Code:
Trigger("flip London").date(900).flip("London",iEngland,False,False,False)
Now London will flip regardless of who owns it (minor/major or AI/human) and the previous owner isn't protected from collapse.

Note however that the dynamic city names (or player named cities) will disable the flip. If you wanna flip any city on the London tile (regardless of its actual name), then you can define a Map Target instead. Look in the documentation for the various ways of defining one. The important thing is to set the name parameter to a None value, which disables it. An example:
Code:
Trigger("flip London").target(53,54).date(900).flip(None,iEngland)
You could do this also, because then the flip() method will simply use all the default parameters:
Code:
Trigger("flip London").target(53,54).player(iEngland).date(900).flip()
This is a good example of how to build your Triggers; Firstly you name it (optional), then you define a map target, and a player target, then some Condition method(s) and finally you use a Action method (or several).
 
You mean that you need one Trigger for spawning the city, and then another one that automatically flips it back to a minor player if acquired by a major player?

Yeah..
Not just back to minor, any AI major city conquered by any another AI Major before the rightful time should be returned automatically to prevent unhistorical event...

Spoiler :
As with any PyScenario event you need to define a Trigger for it. Each Trigger has a Target Player and a Target Tile. For flipping cities you use the flip() method. From the API:

So flipping London to the English on AD 900 you would go:
Code:
Trigger("flip London").date(900).flip("London",iEngland)
There are additional parameters you could use; restricting the flip to minor players only or restricting the flip to AI players only, or to safeguard the current owner from collapse due to the flip. These are all enabled (True) by default, but can easily be disabled (False), like this:
Code:
Trigger("flip London").date(900).flip("London",iEngland,False,False,False)
Now London will flip regardless of who owns it (minor/major or AI/human) and the previous owner isn't protected from collapse.

Note however that the dynamic city names (or player named cities) will disable the flip. If you wanna flip any city on the London tile (regardless of its actual name), then you can define a Map Target instead. Look in the documentation for the various ways of defining one. The important thing is to set the name parameter to a None value, which disables it. An example:
Code:
Trigger("flip London").target(53,54).date(900).flip(None,iEngland)
You could do this also, because then the flip() method will simply use all the default parameters:
Code:
Trigger("flip London").target(53,54).player(iEngland).date(900).flip()
This is a good example of how to build your Triggers; Firstly you name it (optional), then you define a map target, and a player target, then some Condition method(s) and finally you use a Action method (or several).

So, if I want to flip a city (27,38) that belong to any (major,minor,etc) to Inca civilization, at 728AD, the code simply goes like this?

Code:
Trigger("flip Example").target(27,38).player(iInca).date(728).flip()

How do I activate the bSafe=True if the player owning (27,38) at 728 is a Major Civs?
 
Yeah..
Not just back to minor, any AI major city conquered by any another AI Major before the rightful time should be returned automatically to prevent unhistorical event...
So you wanna script the whole game? I don't think PyScenario is the easiest way to achieve this...

So, if I want to flip a city (27,38) that belong to any (major,minor,etc) to Inca civilization, at 728AD, the code simply goes like this?

Code:
Trigger("flip Example").target(27,38).player(iInca).date(728).flip()
No, because the default settings of flip() are:
flip( name=None, eOwner=None, bMinorsOnly=True, bAIOnly=True, bSafe=True )
Those True values mean that only minor Civs are allowed, and only AI Civs. What you wanna do is set those parameters to False:
Code:
Trigger("flip Example").target(27,38).player(iInca).date(728).flip(bMinorsOnly=False, bAIOnly=False)

How do I activate the bSafe=True if the player owning (27,38) at 728 is a Major Civs?
There seems to be no support for this sort of thing. But if you learn Python scripting for real, then you'll be able to do whatever you want. It would be less work for you than it would be for me to rewrite the application.
 
I'm currently learning Python from your signature, etc..
Slow but sure ;)

Okay thanks for the code fix..
Oh, and never mind the rest..

EDIT

Baldyr,
when the screen show No Valid Scenario Module found, is that mean there's something wrong with Scenario.py only or there's might be something wrong with the CvRFCEventHandler.py or PyScenario.py as well?
I was playing with CvRFCEventHandler a bit..
But the game is not crashing =_=
 
Ok, I'm finally ready to continue work on PyScenario. I have about a one month window for programming/modding and after that I may not get another chance. (I will be technically home-less for a while and my desktop computer will be stored away.)

As soon as I can muster the focus I'll start compiling a to-do-list for what needs to be done for the next (final?) version. This would also be the time to remind me of what needs to be added/fixed - and to put forward new requests. Hopefully I will get something finished during next week, but no promises.
 
Top Bottom