Question to Python experts!!

Houman

TR Team Leader
Joined
Jan 24, 2002
Messages
1,083
A question pops up in my mind; would it be possible to declare a global variable in Python that is alive through many turns?

Razing cities is going to fast in my opinion, while pillaging takes much longer than razing a whole city.

I thought I could determine the value for a global variable through the size of the city, is smaller than 5 pop, 3 turns, smaller than 10, 5 turns etc.

This number will be always determined for each city after end turn. if someone tries to raze a city, a trigger will be fired that allows the razing after so many turns like in the global variable.

But this won't be probably possible, since if the OnRaze function is called, it would be already too late. Maybe then, if the enemy has conquered the city in so many turns as in the global variable, then it should allow the Razing function (blocked before through a Boolean variable)

What do you think, is that possible?
Thanks
Houman
 
The problem with doing that surt is that the value of the variable will be lost if the game is saved and then reloaded. You might want to use something like SD-Toolkit to save the variable.
 
Being sneakier than I am talented I would throw unrest on the city for how ever many turns you want, then drop a building in it that checks every turn to see if the city is on unrest. When its not the building destroy's the city.

Not ideal for every occasion of course but it would work and be easy. Just requires a little python to kick off the event (start the unrest and place the building) and some python in the oncitydoturn that performs the check if the building exists.

Or if you wanted to be even simpliar you could just drop a building in the city that took away a population per turn until the city was at 1 population, then just destroyed it.
 
@Kael,

I always like your ideas. ;)

Both ideas are quite nice, the first one is a bit nicer, since it gives the other faction to fight back and reconquer the city before it has been razed.

The second one is nice too, the population gets butchered each turn, until every one has left the city.

One thing is still not clear, where do I start doing this? In OnCityRaze() function? or would that be already too late?

Thanks
Houman
 
SD Toolkit

It can be used to create a data storage device that goes in to memory of the saved game. I use it to determine teh next numbered name of a unit built rather it be sea, land or air. (EX: 1stArmy 5thCorp 8thDiv)

You would have to learn what happens whena city is captured, I.E. what is called, OnRaze, or whatever. Then capture that event in your own code and make it do something different than what is default in the game.

I am not an expert but from what I have learned thus far whatever you declare in your own mod or custom folder trumps the game default event.
 
Houman said:
@Kael,

I always like your ideas. ;)

Both ideas are quite nice, the first one is a bit nicer, since it gives the other faction to fight back and reconquer the city before it has been razed.

The second one is nice too, the population gets butchered each turn, until every one has left the city.

One thing is still not clear, where do I start doing this? In OnCityRaze() function? or would that be already too late?

Thanks
Houman

I would disable razing in the game options then allow cities to create a "Raze" building. You will have to block the building in cannotconstruct to keep over eager AI's from overbuilding them. I would recommend a check for the AI based on maintenance cost and the relative value of the city so the AI is able to make intellegent decisions about if it should keep or raze its own cities.
 
TheLopez said:
The problem with doing that surt is that the value of the variable will be lost if the game is saved and then reloaded. You might want to use something like SD-Toolkit to save the variable.

True, I mostly play straight through so I didn't think about that issue.

He could also use pickle:
http://docs.python.org/tut/node9.html#SECTION009220000000000000000

Pickle is really, really easy to use for save/load stuff.
 
Hey guys,

I still had no time to implement it by myself. Anyone likes to join the Realism: The Third Ressurection Open source project? :)
http://sourceforge.net/projects/civ4mods

Besides I have another question, since we that it is possible removing religions thorugh an inquisition building. Can we make somehow the first CIV that accepts Judaism as state religion in a way that it cannot get any new religions in his state and neither can it spread his religion to others?

That would add so much more realism in the mod. Any idea please?
Thanks
Houman
 
Houman said:
Hey guys,

I still had no time to implement it by myself. Anyone likes to join the Realism: The Third Ressurection Open source project? :)
http://sourceforge.net/projects/civ4mods

Besides I have another question, since we that it is possible removing religions thorugh an inquisition building. Can we make somehow the first CIV that accepts Judaism as state religion in a way that it cannot get any new religions in his state and neither can it spread his religion to others?

I don't know about "the first civ to accept judaism as the state religion" but it would be easy to tie to the owner of the jewish holy city.

Yes, just put your functions in the onReligionSpread function. Do a check to see if the owner of the city is the owner of the jewish holy sity, if it is and the religion is anythng other than judism then remove it. If it is judism then add it. Likewise if the owner of the city isnt the owner of the jewish holy city and the religion is judism then remove it.

That would add so much more realism in the mod. Any idea please?
Thanks
Houman

As for realism, I don't know. There is a difference between realism in making sure things happen logically and realism in trying to mimic the real worlds history. Still I know judism is more hereditary than other religions so this makes the most sense for them, but whose to say in another time and place that judism couldn't have spread and become the dominant religion in multiple coutries and across multiple ethnic groups?
 
Kael, you indeed are very wise. You are one of the few people who really understand what civ is about.
 
Kael,

Thank you so much for this solution I will try it out. :)

Regarding your comment; no it couldn't. Jahweh was from beginning a tribal God that only was there for its own people or the "Chosen People". This is the reason why Jewish always have seen themselves as the Chosen Ones; you are born Jewish or you do not belong to the Chosen People. Therefore Judaism could never have the ability to spread in first place unlike most other religions that were universal. Thats why even different events in the history could have NOT affected this fact. Therefore unrealistic.

Best Regards
Houman
 
Top Bottom