View Full Version : [HOWTO] avoid King's embargos?


espartaco
Nov 12, 2008, 08:28 PM
Well, you can't avoid your King's embargos on goods when you refuse a tax increase.
The good news is that the embargo does not last forever anymore (as much as I hate the US embargo on Cuba).
This would require some changes to the C++ code so here we are:



We are going to make changes to CvPlayer.h and CvPlayer.cpp.

CvPlayer.h:




public:
// ESPARTACO: overcoming King's embargo START
// so far, no need to export these two methods
int getEmbargoOnYieldTurns(YieldTypes eYield) const;
void changeEmbargoOnYieldTurns(YieldTypes eYield, int iChange) const;
// ESPARTACO: overcoming King's embargo END

protected:
// ESPARTACO: overcoming King's embargo START
int* m_aiEmbargoOnYieldTurns;
// ESPARTACO: overcoming King's embargo END

// ESPARTACO: overcoming King's embargo START
void doEmbargos(void);
// ESPARTACO: overcoming King's embargo END




CvPlayer.cpp:

somewhere beginning of file after #includes:



// ESPARTACO: overcoming King's embargo START
// Number of turns for an embargo
static const int EMBARGO_TURNS = 10; // TODO: move this number to an XML file
// ESPARTACO: overcoming King's embargo END




CvPlayer constructor:




// ESPARTACO: overcoming King's embargo START
m_aiEmbargoOnYieldTurns = new int[NUM_YIELD_TYPES];
// ESPARTACO: overcoming King's embargo END




CvPlayer destructor:




// ESPARTACO: overcoming King's embargo START
SAFE_DELETE_ARRAY(m_aiEmbargoOnYieldTurns);
// ESPARTACO: overcoming King's embargo END




reset() method:




for (iI = 0; iI < NUM_YIELD_TYPES; iI++)
{

// ESPARTACO: overcoming King's embargo START
m_aiEmbargoOnYieldTurns[iI] = 0;
// ESPARTACO: overcoming King's embargo END


}




doTurn() method;




verifyCivics();

doPrices();

doEvents();

// ESPARTACO: overcoming King's embargo START
doEmbargos();
// ESPARTACO: overcoming King's embargo END




handleDiploEvent() method:




case DIPLOEVENT_REFUSE_TAX_RATE:
{
AI_changeMemoryCount(ePlayer, MEMORY_REFUSED_TAX, 1);
CvPlayer& kPlayer = GET_PLAYER(ePlayer);
YieldTypes eYield = (YieldTypes) iData1;
kPlayer.setYieldEuropeTradable(eYield, false);

// ESPARTACO: overcoming King's embargo START
// I don't understand this so it is commented out
//kPlayer.setYieldTradedTotal(eYield, 0);
// ESPARTACO: overcoming King's embargo END

CvCity* pCity = kPlayer.getCity(iData2);




setYieldEuropeTradable() method:




if (bOldTradeable != isYieldEuropeTradable(eYield))
{
validateTradeRoutes();

// ESPARTACO: overcoming King's embargo START
if(bTradeable == false)
{
// start embargo on this good
m_aiEmbargoOnYieldTurns[eYield] = EMBARGO_TURNS;
}
// ESPARTACO: overcoming King's embargo END
}





new methods():




// ESPARTACO: overcoming King's embargo START
int CvPlayer::getEmbargoOnYieldTurns(YieldTypes eYield) const
{
FAssert(eYield > -1);
FAssert(eYield < NUM_YIELD_TYPES);
return m_aiEmbargoOnYieldTurns[eYield];
}

void CvPlayer::changeEmbargoOnYieldTurns(YieldTypes eYield, int iChange) const
{
FAssert(eYield > -1);
FAssert(eYield < NUM_YIELD_TYPES);
m_aiEmbargoOnYieldTurns[eYield] += iChange;
}

void CvPlayer::doEmbargos(void)
{
if(getParent() == NO_PLAYER) // no King?
{
return;
}

for(int iYield = 0; iYield < NUM_YIELD_TYPES; iYield++)
{
YieldTypes eYield = (YieldTypes)iYield;

// is there an embergo on this good?
if(m_abYieldEuropeTradable[iYield] == false)
{
// is time to lift the embargo?
m_aiEmbargoOnYieldTurns[iYield]--;
if(m_aiEmbargoOnYieldTurns[iYield] <= 0)
{
m_aiEmbargoOnYieldTurns[iYield] = 0;

setYieldEuropeTradable(eYield, true);

// TODO: i18n this message; add yield icon?
CvWString szMessage = CvWString::format(L"Embargo on %s has been lifted!", GC.getYieldInfo(eYield).getDescription());

// TODO: beutify better this message? include a popup? sounds?
bool bForce = true;
int iLength = GC.getEVENT_MESSAGE_TIME();
LPCTSTR pszSound = NULL;
InterfaceMessageTypes eType = MESSAGE_TYPE_MAJOR_EVENT;
LPCSTR pszIcon = NULL;
ColorTypes eFlashColor = (ColorTypes)GC.getInfoTypeForString("COLOR_GREEN");
gDLL->getInterfaceIFace()->addMessage(getID(),
bForce,
iLength,
szMessage,
pszSound,
eType,
pszIcon,
eFlashColor);
}
}
}
}

// ESPARTACO: overcoming King's embargo END





read() method:




pStream->Read(NUM_YIELD_TYPES, m_abYieldEuropeTradable);

// ESPARTACO: overcoming King's embargo START
pStream->Read(NUM_YIELD_TYPES, m_aiEmbargoOnYieldTurns);
// ESPARTACO: overcoming King's embargo END

pStream->Read(NUM_FEAT_TYPES, m_abFeatAccomplished);





write() method:




pStream->Write(NUM_YIELD_TYPES, m_abYieldEuropeTradable);

// ESPARTACO: overcoming King's embargo START
pStream->Write(NUM_YIELD_TYPES, m_aiEmbargoOnYieldTurns);
// ESPARTACO: overcoming King's embargo END

pStream->Write(NUM_FEAT_TYPES, m_abFeatAccomplished);







Some changes are just boiler plate stuff. I didn't bother with i18n of strings and the embargo duration in turns is hard coded as 10 turns to quickly test this feature.

Pictures are next...

espartaco
Nov 12, 2008, 08:30 PM
Lifting the embargo could be a more important message such as a popup, for now it is a simple message:

espartaco
Nov 12, 2008, 08:36 PM
BTW, never played Col 1.
Where can I buy a copy of Col 1?

Dale
Nov 12, 2008, 10:55 PM
Sorry, but if an embargo lifts automatically then it kills strategy around parties. You would ALWAYS throw the party to avoid tax increases. That's a no-brainer! 10 turns of inconveniance to avoid a tax hike....... that's not just an exploit, I class that as a major cheat!

:eek: :eek:

espartaco
Nov 12, 2008, 11:20 PM
As I said, 10 turns was chosen just for testing. Also I indicated to pull out this number to an XML file so a player would change to whatever he/she likes.
I enjoy my changes as much as I like programming in C/C++/Java/Python which I do for my living. Driving home this afternoon I designed this feature in my mind and in a couple of minutes I had this implementation which I really enjoy, when I get a tax increase I just give my King a finger and wait for the embargo to be lifted. That's all. But thanks for your comment, I like your posts and your commitment to make this game better is really appreciated.

Dale
Nov 13, 2008, 01:25 AM
If I can suggest, that an embargo should be lifted (like in Col1) when you paid your backtaxes. Not automatically. That way there is a strategic decision in throwing parties.

espartaco
Nov 13, 2008, 06:43 AM
My last test was with an embargo = 30 turns. The game is responding very nicely (yeah, point to Firaxis! :goodjob:). The tax increase events are happening more often :eek:. Soon I was running out of trade options :mad:. My warehouses were filling up with goods which I couldn't sell :mad:. I couldn't buy guns, horses to trade with the natives :mad:. While waiting for those 30 agonizing turns :crazyeye:.
So my rebellious behavior was making a heavy toll on my economy. I told myself, wow, I just discovered a very nice twist in this game.
Of course, a low embargo would definitely avoid tax increases.
embargo = 1 turn would be overkill.
embargo = 300 turns would behave like the original game as if this feature didn't exist at all.
embargo = 10 turns was my initial trial but I was more concerned with finding bugs or errors although I noted that the economy was not doing well.
I will test with 40, 60 or even 100 turns. The higher the number of turns the closer to the original forever embargo.
Which brings me to the bottom line: what is the point of having a forever embargo? what would you do with your cigars? stick them into your ears? At least, with this change, you hope, that some day(turns), you would be able to resume trading your cigars again. On the other hand, what to do? dismiss your cigar makers? dismiss your tobacco planters? your wagons? destroy all that you created so diligently from turn zero? No thanks, I prefer making cigars for 249 turns, at turn 250 declare independence and give my tobacco guys a gun and kick them out to join the fight.
Some people like to play accepting every tax increase and silently accepting those outrageous tax burdens. Other people like me prefer having the opportunity to say the f... word to the King, give him a finger, even if later on we have to give up to his demands, like in real life.
Of course, more elaborated implementation could be added, like paying back due taxes or some other events to justify lifting the embargo. But in essence, this change is adding a new excitement to the game and I really enjoy it.
- Long live our beloved King!
- Yes, until the next tax increase....