Requesting following features

Nice! :goodjob:

I'm done with testing the dummy rebellion class now, so I'd say that all of the basic code is done for this module. The next step is to create sub-classes for the various types of rebellions... But most of them require additional work from you, even if I can start building the framework right away. I can also take a closer look at how the cultural rebellion could be realized to your specifications...
 
ok, can't wait for it to be all ready! below is a spoiler which is in fact a spoiler... open if you really want to...

Spoiler :

attachment.php


btw I hand made all of this (apart from the text) I am very pleased by the helmet!


what sort of work will I have to be doing?
 

Attachments

  • Civ4ScreenShot0139.JPG
    Civ4ScreenShot0139.JPG
    66.3 KB · Views: 531
Oh, add all the civs/players to the wbs so that I can access them. Then get all the Tech and Unit XML stuff in order so that we can map the Techs against the rebel unit types. And finally figure out how to calculate the number of occupation rebel units.

I'm sure I will prompt you with design decisions every step of the way, so I think you'll be able to keep busy. ;)

What about the Byzantium code, by the way? I think I kinda forgot about it. :p
 
we shall deal with that later! I will get on with those soon... I will pack up everything for you and send them over (may take a while) etc...

how did you like the spoiler? (that's if you looked in it)
 
It looked great! :goodjob:
 
I'm looking at the various rebellion type entries you wrote up and seeing different probability percentages, ranging from 7% to 25%. I'd like to note, however, that since any city will only be checked every 8 turns - then this really equates to a perceived probability of 12,5% for the event to trigger on any given turn. So you could probably calculate with something like an average city disorder of 4-6 turns or something, making the base probability for any rebellion triggered by disorder 50-75%.

But in the name of moving forward I will give you the option of setting a percentile constant for each type in the ModSettings module. I'll set them all to 100 by default so that you can lower them yourself to whatever turns out to be most balanced. Just remember that the condition is checked every 8 turns and that the base probability hence really depends on how long the conditions (disorder or not) are in place.
 
I'm still pondering how to identify which rival is threatening a city to flip. Could it be as simple as the player with the most foreign culture in the city?

If I can't identify this player once the rebellion event triggers, then there might be odd results. Spawning rebel units for the wrong player, to be more exact... :rolleyes:
 
yeah most foreign culture but make sure the previous owner(s) are excluded because other wise when you conquor a city it might just flip back to previous owner(s)
 
IT may not be as simple as most culture...

I think it is "most culture for a which there is a city that has this city within its cultural range".

Example: You took a city from civ A and it has 60% civ A culture but there is no civ A city that has a cultural range that reaches this city. There is a civ B that has 39% culture (and you have 1%) in this city and a civ B city close enough that this city is within its cultural range then it is civ B that will flip your city to them, not civ A.

Which brings up the issue that a civ can't flip a city back to themselves that was captured militarily unless the game option that allows this is turned on.
 
yeah most foreign culture but make sure the previous owner(s) are excluded because other wise when you conquor a city it might just flip back to previous owner(s)
I think you're getting this wrong. I'm not trying to influence what player (previous owner or not) is threatening the city with a flip. I don't even think this is possible, so you can rest assured that I won't do anything like that.

Instead, I need to be able to figure out what player is causing the disorder - in order to spawn rebel units for that player.

But I guess I'll just use the player (except the current owner) with the highest culture in the city. You'll be able to test what happens yourself...

Furthermore: How would one go about detecting that "cultural disorder" is happening in a city? If a city is in disorder and not under occupation, then it must be cultural influence causing it, right? But what about Espionage? (How does that really work, anyway? If ts just a one turn affair, then it could be possible to not fire on the first turn.)
 
i'm not really sure but their are random events and such that make revolts. but look for cultural revolts and see what you can come up with
 
Here's an example of how the sub-classes of rebellions are setup:
Spoiler :
Code:
class CulturalRebellion(Rebellion):

    @classmethod
    def checkConditions(cls, pCivPlayer, pCity):
        return ( [COLOR="SeaGreen"]pCity.isDisorder()
                 and not pCity.isOccupation()
                 and not pCity.isNeverLost()
                 and isChance(iCulturalRebellionPercentage)[/COLOR] )

    def setRebelPlayer(self, pCity):
        self.eRebelPlayer = getHighestCityCulturalRival(pCity)
        [COLOR="Red"]if self.eRebelPlayer == -1:
            self.eRebelPlayer = eBarbarian[/COLOR]

    def setNumUnits(self, pCity):
        self.iNumUnits = max(1, pCity.getCulturePercentAnger() / 100)
Note that there are four conditions (green) and if there still is no foreign culture in the city, then the event will spawn Barbarian units as a default (red). This could probably only happen if the disorder in the city was initiated by a espionage mission. This is necessary in order to avoid an exception to occur at these instances - unless I can figure out a way to create a condition that excludes espionage disorder.

I know you specifically didn't want the rebellion to take place if the cultural threat is coming from the previous owner. I haven't implemented this however, as I guess you need to enable the GAMEOPTION_NO_CITY_FLIPPING or possible not enable the GAMEOPTION_FLIPPING_AFTER_CONQUEST in the WBS. Chances are that you would end up with not cultural rebellions at all - except those prompted by espionage missions...

The other 200 some lines of code are automatically inherited from the parent Rebellion class. Because the above code is all that distinguishes cultural rebellions from the default template for rebellions. Convenient to work with! :goodjob:
 
you should probably set the default as civ specific instead of barbs! otherwise looks good! just make sure it doesn't conflict with the domestic rebellions...
 
I'm having trouble with this:
Type - Domestic Rebellion

Sample Conditions - Disorder for whatever reason 12% for barbs and 7% for civilized

Civ Claimant - Civ Specific rebels (I will send you the current mod soon)

Number of Units - Revolt turns * Military Garrison strength + 1 strength (may be unbalanced but testing will see) OR iPopulation / 2 * iUnhappyLevel + iDistance possibly?

Type - Current owner's tech level

Termination - None

Misc - Revival would be for rebels, Always present, War weariness
Firstly, the civilized probability should always be 5% lower than the non-civilized, right? (Because I will set the base chance at 100% by default, so that would mean that the civilized players have a 95% chance. See previous post on more on the probability issues.)

Secondly, I can't find any easy way to detect how many turns a city has been in disorder. (Or did you really mean how long the rebellion event has been active? Is it spawning units during all its length?) I guess I could build an entire system that checks all cities every turn and keeps track of whether or not they are in disorder, and stores a custom number of game turns value for each city. But I'd rather not - because of the lag involved.

I suggest you rethink the calculation.

Also, what do you mean by the "OR" operator? One either needs be higher or lower than the other. Because the exact calculation isn't being decided randomly, right?

What about war weariness? Only in the rebelling city or in all cities? How much war weariness? Just one modifier at the beginning of the event - or accumulating penalties during the length of the rebellion? (How much does it go up by in the latter case? +1? How often? Every other turn, perhaps? Randomly? Is there a upper cap on how much war weariness the rebellion can cause?)

Furthermore, this is the preliminary code for the occupation rebellion, dubbed the Resistance class:
Spoiler :

Code:
class Resistance(Rebellion):

    @classmethod
    def checkConditions(cls, pCivPlayer, pCity):
        return ( pCity.isDisorder()
                 and pCity.isOccupation()
                 and isChance(iResistancePercent) )

    def setRebelPlayer(self, pCity):
        self.eRebelPlayer = pCity.getPreviousOwner()

    def setUnitType(self, pCity):
        self.eUnitType = getTechUnitType(self.getRebelCiv().get(CyTeam))

    def setNumUnits(self, pCity):
        iNatives = pCity.getCulturePercentAnger() / 100
        iPopulation = pCity.getPopulation()
        self.iNumUnits = [COLOR="SeaGreen"]max(1, min(iNatives, iPopulation))[/COLOR]

[COLOR="Red"]    def process(self):
        if ( Game.getGameTurn() - self.getRebellionTurn() >= iResistanceDomesticTurns
             and isChance(iResistanceDomesticPercentage) ):
            self.killRebelUnits()
            removeRebellion(self)
            pDomesticRebellion = DomesticRebellion.initRebellion(self.getCityOwner(), self.getCyCity())
            appendRebellion(pDomesticRebellion)[/COLOR]
Perhaps the previous owner should automatically end up at war with the current owner once the event fires? Or should a state of war be a prerequisite condition for the rebellion to take place?

The number of rebel units (green) is tentatively defined by the number of foreign citizens (natives) - capped by the actual city size.

The process() method at the end (red) will in iResistanceDomesticPercentage cases out of 100 terminate the occupation rebellion after iResistanceDomesticTurns (checked once a turn) and initiate a (new) domestic rebellion instead. All the foreign rebel units from the first rebellion are disbanded and new civ specific rebel units are spawned.
 
you should probably set the default as civ specific instead of barbs! otherwise looks good! just make sure it doesn't conflict with the domestic rebellions...
Yeah, that makes sense. I think I'll use a general "no other rebellions active in this city" condition for the domestic rebellions. That would keep it from conflicting with any other type of rebellion.
 
(Did you notice me previous post, by the way?)
 
oops sorry!


right ok the OR states that I don't know which one to use but I guess the "iPopulation / 2 * iUnhappyLevel + iDistance" will have to be the calculation!


I have 2 ideas for the war weariness:
1. all cities gain war weariness capped out at 3 (so it can grow like normal war weariness but ends at 3)
2. The Capital City gains a "Our cities are in rebellion!" unhappiness modifier which gives 2 unhappiness


I don't know whether war should be a prereq possibly... not sure...
 
right ok the OR states that I don't know which one to use but I guess the "iPopulation / 2 * iUnhappyLevel + iDistance" will have to be the calculation!
Ok, I'll figure out how to calculate the distance from capital then. I should be fun.

I have 2 ideas for the war weariness:
1. all cities gain war weariness capped out at 3 (so it can grow like normal war weariness but ends at 3)
2. The Capital City gains a "Our cities are in rebellion!" unhappiness modifier which gives 2 unhappiness
Are both in effect or only one of them? (Which one?)

I looked up war weariness in the API and it turns out that the only way to set it is to work with the player team. So all cities get it simultaneously, which is fine, right?

While it is possible to set extra unhappiness in individual cities (like the capital) the variety is always the default "aarrggh!". I don't know of any way to create a new unhappiness category for rebellions.

With this in mind - how do I proceed?

I don't know whether war should be a prereq possibly... not sure...
This is basically a design decision, and now is the time to make those difficult calls. Because I'm writing the code. :p

This rebellion type is also pretty much in order now:
Spoiler :
Code:
class MinorRevolt(Rebellion):

    @classmethod
    def checkConditions(cls, pCivPlayer, pCity):
        return ( pCity.angryPopulation() > 0
                 and isChance(iMinorRevoltPercentage) )

    def setRebelPlayer(self, pCity):
        self.eRebelPlayer = self.eCityOwner + iNumMajorPlayers
        [COLOR="SeaGreen"]self.updateRebelTechs()
[/COLOR]
    def setNumUnits(self, pCity):
        iUnhappyLevel = pCity.unhappyLevel(0)
        iAngryPopulation = pCity.angryPopulation()
        iPopulation = pCity.getPopulation()
        self.iNumUnits = max(1, min(iUnhappyLevel - iAngryPopulation,[COLOR="Red"] iPopulation[/COLOR]))
This should be more or less exactly what you ordered. I did however add a cap to the number of players at the actual city size (red) - as the unhappy level can get considerably larger than the city... But if this breaks your design I can easily edit it out.

Also note that the rebel civ's techs always get updated (green) once the rebellion launches. Or should this only happen if the rebel civ is revived (as in previously dead)?

Another approach could be to have the game always match every Tech discovered by any of the major players with its rebel variety. This way there is no need to figure out when to update all Techs - because they will always match.

What do you think?

By the way, I added a general condition to the rebellion engine itself, that excludes any cities already in rebellion from being checked for further rebellions. This way we shouldn't have to worry about conflicts between rebellions and rebellion types.
 
Back
Top Bottom