[SDK MODCOMP] Examine City on Conquest!

I tried this, I made two AI civs go to war one I was friendly with. Not in love or anything but maybe +6 or so relations.

Lets call AI civ friendly "AI civ 1" and AI civ unfriendly "AI Civ 2".

I let the AI Civ 2 take AI Civ 1 city and then took the city from AI Civ 2. There was no popup, either I coded it wrong (looks right to me) or that wasn't a good test.
 
Code:
		// examine city start
		[b]if (pPopupReturn->getButtonClicked() == 2)
		{
			gDLL->sendDoTask(info.getData1(), TASK_RAZE, -1, -1, false, false, false, false);
		}[/b]
		else if (pPopupReturn->getButtonClicked() == 3)
		{
			CvCity* pCity = GET_PLAYER(GC.getGameINLINE().getActivePlayer()).getCity(info.getData1());
			if (NULL != pCity)
			{
				gDLL->getEventReporterIFace()->cityAcquiredAndKept(GC.getGameINLINE().getActivePlayer(), pCity);
			}

			gDLL->sendDoTask(info.getData1(), TASK_GIFT, info.getData2(), -1, false, false, false, false);
		}
		else if (pPopupReturn->getButtonClicked() == 1)
		{
			CvCity* pCity = GET_PLAYER(GC.getGameINLINE().getActivePlayer()).getCity(info.getData1());
			if (NULL != pCity)
			{
				pCity->chooseProduction();
				gDLL->getEventReporterIFace()->cityAcquiredAndKept(GC.getGameINLINE().getActivePlayer(), pCity);
			}
		}
		else if (pPopupReturn->getButtonClicked() == 0)
		{
			CvCity* pCity = GET_PLAYER(GC.getGameINLINE().getActivePlayer()).getCity(info.getData1());
			if (NULL != pCity)
			{
				gDLL->getInterfaceIFace()->selectCity(pCity);
				// modify this to call again
				CvPopupInfo* pInfo = new CvPopupInfo(BUTTONPOPUP_RAZECITY);
				pInfo->setData1(info.getData1());
				pInfo->setData2(info.getData2());
				pInfo->setData3(info.getData3());
				gDLL->getInterfaceIFace()->addPopup(pInfo, GC.getGameINLINE().getActivePlayer());
			}			
		}
		// examine city end

Code:
// examine city start
	gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_EXAMINE_CITY2").c_str(), NULL, 0, WIDGET_GENERAL);
	gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_KEEP_CAPTURED_CITY").c_str(), NULL, 1, WIDGET_GENERAL);

	if (bRaze)
	{
		[b]gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_RAZE_CAPTURED_CITY").c_str(), NULL, 2, WIDGET_GENERAL);[/b]
	}
	if (bGift)
	{
		szBuffer = gDLL->getText("TXT_KEY_POPUP_RETURN_ALLIED_CITY", GET_PLAYER(eHighestCulturePlayer).getCivilizationDescriptionKey());
		[b]gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, szBuffer, NULL, 2, WIDGET_GENERAL, 3, eHighestCulturePlayer);[/b]
	}
// examine city end
	gDLL->getInterfaceIFace()->popupLaunch(pPopup, false, POPUPSTATE_IMMEDIATE);
	gDLL->getInterfaceIFace()->playGeneralSound("AS2D_CITYCAPTURE");

When you reordered the code to have the raze city option to appear first, some of them were left as they were originally. So you have both the raze city button and the gift city button tied to the value 2. So when you click 2, it's just razing the city.

All you need to do is change this:
Code:
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, szBuffer, NULL, [b]2[/b], WIDGET_GENERAL, 3, eHighestCulturePlayer);

To this:
Code:
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, szBuffer, NULL, [b]3[/b], WIDGET_GENERAL, 3, eHighestCulturePlayer);

Cheers! :D
 
Last edited:
Code:
		// examine city start
		[b]if (pPopupReturn->getButtonClicked() == 2)
		{
			gDLL->sendDoTask(info.getData1(), TASK_RAZE, -1, -1, false, false, false, false);
		}[/b]
		else if (pPopupReturn->getButtonClicked() == 3)
		{
			CvCity* pCity = GET_PLAYER(GC.getGameINLINE().getActivePlayer()).getCity(info.getData1());
			if (NULL != pCity)
			{
				gDLL->getEventReporterIFace()->cityAcquiredAndKept(GC.getGameINLINE().getActivePlayer(), pCity);
			}

			gDLL->sendDoTask(info.getData1(), TASK_GIFT, info.getData2(), -1, false, false, false, false);
		}
		else if (pPopupReturn->getButtonClicked() == 1)
		{
			CvCity* pCity = GET_PLAYER(GC.getGameINLINE().getActivePlayer()).getCity(info.getData1());
			if (NULL != pCity)
			{
				pCity->chooseProduction();
				gDLL->getEventReporterIFace()->cityAcquiredAndKept(GC.getGameINLINE().getActivePlayer(), pCity);
			}
		}
		else if (pPopupReturn->getButtonClicked() == 0)
		{
			CvCity* pCity = GET_PLAYER(GC.getGameINLINE().getActivePlayer()).getCity(info.getData1());
			if (NULL != pCity)
			{
				gDLL->getInterfaceIFace()->selectCity(pCity);
				// modify this to call again
				CvPopupInfo* pInfo = new CvPopupInfo(BUTTONPOPUP_RAZECITY);
				pInfo->setData1(info.getData1());
				pInfo->setData2(info.getData2());
				pInfo->setData3(info.getData3());
				gDLL->getInterfaceIFace()->addPopup(pInfo, GC.getGameINLINE().getActivePlayer());
			}			
		}
		// examine city end

Code:
// examine city start
	gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_EXAMINE_CITY2").c_str(), NULL, 0, WIDGET_GENERAL);
	gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_KEEP_CAPTURED_CITY").c_str(), NULL, 1, WIDGET_GENERAL);

	if (bRaze)
	{
		[b]gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, gDLL->getText("TXT_KEY_POPUP_RAZE_CAPTURED_CITY").c_str(), NULL, 2, WIDGET_GENERAL);[/b]
	}
	if (bGift)
	{
		szBuffer = gDLL->getText("TXT_KEY_POPUP_RETURN_ALLIED_CITY", GET_PLAYER(eHighestCulturePlayer).getCivilizationDescriptionKey());
		[b]gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, szBuffer, NULL, 2, WIDGET_GENERAL, 3, eHighestCulturePlayer);[/b]
	}
// examine city end
	gDLL->getInterfaceIFace()->popupLaunch(pPopup, false, POPUPSTATE_IMMEDIATE);
	gDLL->getInterfaceIFace()->playGeneralSound("AS2D_CITYCAPTURE");

When you reordered the code to have the raze city option to appear first, some of them were left as they were originally. So you have both the raze city button and the gift city button tied to the value 2. So when you click 2, it's just razing the city.

All you need to do is change this:
Code:
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, szBuffer, NULL, [b]2[/b], WIDGET_GENERAL, 3, eHighestCulturePlayer);

To this:
Code:
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, szBuffer, NULL, [b]3[/b], WIDGET_GENERAL, 3, eHighestCulturePlayer);

Cheers! :D

I revised it so that the 3rd option will be the examine city option and it looks like it will work like that, however, I haven't been able to reproduce a "gift city" option... I can upload as is, it's even simpler code than v.1.0
 
I went ahead and uploaded version 1.1.

It adds the examine option to the end. This is the same location as the option you get when you see the popup for liberating a city..

Code:
"Sire, the citizens of "CityName" are rightfully asking to join the "Other Guy". 
Allowing them to do so would make "the Other Guy" quite pleased with us."

I also just reused the text from that popup so now the code is very tiny since the other options are not renumbered and there is no need for new text..

I haven't been able to reproduce the raze thing gilder was talking about but as he came to the same conclusion I did about using "3" it should work..

Downlink on the first post...
 
Just out of curiosity, did Firaxis end up using this exact code, or did they re-write it?
 
The new patch adds examine city on conquest. I was wondering if they used your code, or wrote it using a different method.
 
Back
Top Bottom