Adding a new mission

Alrik2002

Warlord
Joined
May 24, 2012
Messages
214
Location
Berlin, Germany
Hi,

as I´ve mentioned in another thread, I would like to add a new mission. Units should be able to pillage routes without pillaging the improvements on the same plot. Unfortunatly the icon for the mission don´t show up. In another Mod it worked but unfortunatly not in K-Mod.

It would be very nice if someone could give me a hint what I´ve made wrong.

Here are the files I´ve edited. The new parts of the code are within the comments "Route Pillage" and colored red. I know that I have to edit the parts of the K-Mod which allow to pillage routes but this I would like to do when the new mission is available.

cvdllwidgetdata.cpp
Spoiler :
Code:
        2012 void CvDLLWidgetData::parseActionHelp(CvWidgetDataStruct &widgetDataStruct, CvWStringBuffer &szBuffer)
        ...
	2095 else if (GC.getActionInfo(widgetDataStruct.m_iData1).getMissionType() == MISSION_PILLAGE)
	2096 {
	2097	if (pMissionPlot->getImprovementType() != NO_IMPROVEMENT)
	2098	{
	2099		szBuffer.append(NEWLINE);
	2100		szBuffer.append(gDLL->getText("TXT_KEY_ACTION_DESTROY_IMP", GC.getImprovementInfo(pMissionPlot->getImprovementType()).getTextKeyWide()));
	2101	}
	2102	else if (pMissionPlot->getRouteType() != NO_ROUTE)
	2103	{
	2104		szBuffer.append(NEWLINE);
	2105		szBuffer.append(gDLL->getText("TXT_KEY_ACTION_DESTROY_IMP", GC.getRouteInfo(pMissionPlot->getRouteType()).getTextKeyWide()));
	2106	}
	2107 }
	2108
	[COLOR="Red"]
        2109 // < Route Pillage Start >
	2110 else if (GC.getActionInfo(widgetDataStruct.m_iData1).getMissionType() == MISSION_PILLAGE_ROUTE)
	2111 {
	2112	if (pMissionPlot->getRouteType() != NO_ROUTE)
	2113	{
	2114		szBuffer.append(NEWLINE);
	2115		szBuffer.append(gDLL->getText("TXT_KEY_ACTION_DESTROY_IMP", GC.getRouteInfo(pMissionPlot->getRouteType()).getTextKeyWide()));
	2116	}
	2117 }
	2118 // < Route Pillage End   >[/COLOR]

cvenums.h
Spoiler :

Code:
        1395 enum MissionTypes				// Exposed to Python
        ...
	1444 MISSION_DAMAGE,
	1445 MISSION_MULTI_SELECT,
	1446 MISSION_MULTI_DESELECT,
	1447
[COLOR="Red"]
        1448 // < Route Pillage Start >
	1449 MISSION_PILLAGE_ROUTE,
	1450 // < Route Pillage End   >
[/COLOR]
        1451 #ifdef _USRDLL
        1452	NUM_MISSION_TYPES
        1453 #endif
        1454 };

cvselectiongroup.cpp
Spoiler :

Code:
	588 CvPlot* CvSelectionGroup::lastMissionPlot()
	...
	626 case MISSION_RANGE_ATTACK:

	627 case MISSION_PILLAGE:

[COLOR="Red"]
	628 // < Route Pillage Start >

	629 case MISSION_PILLAGE_ROUTE:

	630 // < Route Pillage End   >
[/COLOR]
	631 case MISSION_SABOTAGE:

	632 case MISSION_DESTROY:


	...


	680 void CvSelectionGroup::startMission()
	...
	805 case MISSION_BOMBARD:

	806 case MISSION_RANGE_ATTACK:

	807 case MISSION_PILLAGE:

[COLOR="Red"]
	808 // < Route Pillage Start >

	809 case MISSION_PILLAGE_ROUTE:
	810 // < Route Pillage End   >
[/COLOR]
	811 case MISSION_SABOTAGE:

	812 case MISSION_DESTROY:
	...
	1019 case MISSION_PILLAGE:
	1020	/*if (pLoopUnit->pillage())

	1021	{

	1022		bAction = true;
	
	1023	}*/
	
	1024	FAssertMsg(false, "MISSION_PILLAGE handled incorrectly."); // K-mod (see above)

	1025	break;

	
	1026
[COLOR="Red"]
	1027 // < Route Pillage Start >
	
	1028 case MISSION_PILLAGE_ROUTE:

	1029 	if (pLoopUnit->pillageRoute())
	
	1030	{

	1031		bAction = true;

	1032	}

	1033	break;
	
	1034 // < Route Pillage End   >

	
	1035
[/COLOR]
	1036 case MISSION_PLUNDER:

	1037	if (pLoopUnit->plunder())
	
	1038	{

	1039		bAction = true;
	
	1040	}

	1041	break;


	...


	1270 bool CvSelectionGroup::continueMission_bulk(int iSteps)
	...
	1440 case MISSION_BOMBARD:

	1441 case MISSION_RANGE_ATTACK:
	
	1442 case MISSION_PILLAGE:

[COLOR="Red"]
	1443 // < Route Pillage Start >
	
	1444 case MISSION_PILLAGE_ROUTE:

	1445 // < Route Pillage End   >
	
[/COLOR]
	1446 case MISSION_SABOTAGE:

	1447 case MISSION_DESTROY:
	...
	1530 case MISSION_BOMBARD:

	1531 case MISSION_RANGE_ATTACK:
	
	1532 case MISSION_PILLAGE:

[COLOR="Red"]
	1533 // < Route Pillage Start >
	
	1534 case MISSION_PILLAGE_ROUTE:

	1535 // < Route Pillage End   >
	
[/COLOR]
	1536 case MISSION_SABOTAGE:

	1537 case MISSION_DESTROY:


	...


	3797 bool CvSelectionGroup::canDoMission(int iMission, int iData1, int iData2, CvPlot* pPlot, bool bTestVisible, bool bCheckMoves)
	...
	3946 case MISSION_PILLAGE:

	3947	if (pLoopUnit->canPillage(pPlot) && (!bCheckMoves || pLoopUnit->canMove()))

	3948		return true;

	3949	break;
	3950
[COLOR="Red"]
	3951 // < Route Pillage Start >

	3952 case MISSION_PILLAGE_ROUTE:

	3953	if (pLoopUnit->canPillageRoute(pPlot) && (!bCheckMoves || pLoopUnit->canMove()))

	3954		return true;

	3955	break;

	3956// < Route Pillage End   >


[/COLOR]
	3957 
	3958 case MISSION_SABOTAGE:

	3959	if (pLoopUnit->canSabotage(pPlot, bTestVisible) && (!bCheckMoves || pLoopUnit->canMove()))

	3960		return true;

	3961	break;

CvUnit.cpp
Spoiler :

Code:
[COLOR="Red"]
	4988 // < Route Pillage Start >
	4989 bool CvUnit::canPillageRoute(const CvPlot* pPlot) const
	4990 {

	4991	if (!(m_pUnitInfo->isPillage()))

	4992	{

	4993		return false;

	4994	}

	
	4995	
	4996	if (pPlot->isCity())

	4997	{

	4998		return false;

	4999	}


	5000
	5001	if (!(pPlot->isRoute()))

	5002	{

	5003		return false;

	5004	}
	5005
	5006	if (pPlot->isOwned())
	5007	{

	5008		if (!atWar(pPlot->getTeam(), getTeam()))

	5009		{

	5010			if (pPlot->getOwnerINLINE() != getOwnerINLINE())

	5011			{

	5012				return false;

	5013			}

	5014		}

	5015	}


	5016
	5017	if (!(pPlot->isValidDomainForAction(*this)))

	5018	{

	5019		return false;
	5020	}
	5021
	5022	return true;

	5023 }
	5024 
// < Route Pillage End >

[/COLOR]	
	5025
	5026 
bool CvUnit::pillage()


	...


[COLOR="Red"]	
	5164 // < Route Pillage Start >
	5165 bool CvUnit::pillageRoute()

	5166 {

	5167	CvPlot* pPlot;

	5168	CvWString szBuffer;


	5169
	5170	if (!canPillageRoute(plot()))

	5171	{

	5172		return false;

	5173	}


	5174
	5175	pPlot = plot();


	5176
	5177	if (pPlot->isRoute())

	5178	{

	5179		pPlot->setRouteType(NO_ROUTE, true); // XXX downgrade rail???
	
	5180	}


	5181
	5182	changeMoves(GC.getMOVE_DENOMINATOR());


	5183	
	5184	if (pPlot->isActiveVisible(false))

	5185	{

	5186		// Pillage entity mission

	5187		CvMissionDefinition kDefiniton;

	5188		kDefiniton.setMissionTime(GC.getMissionInfo(MISSION_PILLAGE_ROUTE).getTime() * gDLL->getSecsPerTurn());

	5189		kDefiniton.setMissionType(MISSION_PILLAGE_ROUTE);

	5190		kDefiniton.setPlot(pPlot);

	5191		kDefiniton.setUnit(BATTLE_UNIT_ATTACKER, this);

	5192		kDefiniton.setUnit(BATTLE_UNIT_DEFENDER, NULL);

	5193		gDLL->getEntityIFace()->AddMission(&kDefiniton);

	5194	}

	
	5195
	5196 return true;

	5197 }
	5198 
// < Route Pillage End   >
[/COLOR]
	5199
	5200 bool CvUnit::canPlunder(const CvPlot* pPlot, bool bTestVisible) const

CvUnit.h
Spoiler :

Code:
	67 class CvUnit : public CvDLLEntity
	...
	179 bool canPillage(const CvPlot* pPlot) const;																										// Exposed to Python

	180 bool pillage();
[COLOR="Red"]
	181 // < Route Pillage Start >

	182 bool canPillageRoute(const CvPlot* pPlot) const;																										// Exposed to Python

	183 bool pillageRoute();
	
	184 // < Route Pillage End   >
[/COLOR]

cyenumsinterface.cpp
Spoiler :

Code:
	1054 .value("MISSION_MULTI_SELECT", MISSION_MULTI_SELECT )

	1055 .value("MISSION_MULTI_DESELECT", MISSION_MULTI_DESELECT )

[COLOR="Red"]
	1056 // < Route Pillage Start >

	1057 .value("MISSION_PILLAGE_ROUTE", MISSION_PILLAGE_ROUTE)

	1058 // < Route Pillage End   >
[/COLOR]

CyUnit.cpp
Spoiler :

Code:
	257 bool CyUnit::canPillage(CyPlot* pPlot)
	258 {

	259	return m_pUnit ? m_pUnit->canPillage(pPlot->getPlot()) : false;

	260 }
	261
[COLOR="Red"]
	262 

// < Route Pillage Start >

	263 bool CyUnit::canPillageRoute(CyPlot* pPlot)

	264 {
	265return m_pUnit ? m_pUnit->canPillageRoute(pPlot->getPlot()) : false;
	266 }
	267 
// < Route Pillage End   >
[/COLOR]

CyUnit.h
Spoiler :

Code:
	81 bool canBombard(CyPlot* pPlot);

	82 bool canPillage(CyPlot* pPlot);


	83
[COLOR="Red"]
	84 // < Route Pillage Start >

	85 bool canPillageRoute(CyPlot* pPlot);
	86 // < Route Pillage End   >
[/COLOR]

cyunitinterface1.cpp
Spoiler :

Code:
	79 .def("canPillage", &CyUnit::canPillage, "bool (CyPlot* pPlot)")


	80
[COLOR="Red"]
	81 // < Route Pillage Start >

	82 .def("canPillageRoute", &CyUnit::canPillageRoute, "bool (CyPlot* pPlot)")

	83 // < Route Pillage End   >
[/COLOR]

Thank you very much for your help!
 
The displaying of buttons is handled by the python code. You'll have to change something there. I'm not certain where, but if I was trying to do it, I'd start by looking in CvMainInterface.py.

Also, you'll probably have to change some xml somewhere to tell the game which graphics it should use for the new button. You might get more help if you asked about this in the general modding forum.
 
Thanks for your answer. The Mod-component came without any python-stuff, so I don´t have to change anything there. So I checked the Civ4MissionInfos.xml, which I´ve copied from my old mod. The mission itself is there and defined correctly but than I saw, that directly above were some missions which are not used anymore. I deleted them and now it works!

Yeah. Now I can start to enjoy your great mod and share it with my friends to play a pitboss game with hopely much less OOS-errors.
 
Back
Top Bottom