At first I apologize my bad English. Some parts of this text might be difficult to read and grammar awful. But try to cope with it.
My previous programming knowledge is only merging. I was planning to change the City/Improvement bombing so it could destroy routes too. Unfortunately I'm not too familiar with sdk coding so I decided to ask help. I thought that it might be handled in CvUnit.cpp. The only problem was tha there was few different functions and I didn't know witch one to edit.
I thought the first function checks just if the unit can bomb and the second checks more if you can bomb and the third does all the work. Please correct me if I'm wrong.
I don't think I need to edit the first function at all. But should I check in the second fuction if the plot has route? This is just a ques but would it look something like this:
But that's all I know I should do. I have no idea what I should add to the third function. So could anyone with some sdk knowledge teach me little more about it?
My previous programming knowledge is only merging. I was planning to change the City/Improvement bombing so it could destroy routes too. Unfortunately I'm not too familiar with sdk coding so I decided to ask help. I thought that it might be handled in CvUnit.cpp. The only problem was tha there was few different functions and I didn't know witch one to edit.
Spoiler :
Code:
bool CvUnit::canAirBomb(const CvPlot* pPlot) const
{
if (getDomainType() != DOMAIN_AIR)
{
return false;
}
if (airBombBaseRate() == 0)
{
return false;
}
if (isMadeAttack())
{
return false;
}
return true;
}
bool CvUnit::canAirBombAt(const CvPlot* pPlot, int iX, int iY) const
{
CvCity* pCity;
CvPlot* pTargetPlot;
if (!canAirBomb(pPlot))
{
return false;
}
pTargetPlot = GC.getMapINLINE().plotINLINE(iX, iY);
if (plotDistance(pPlot->getX_INLINE(), pPlot->getY_INLINE(), pTargetPlot->getX_INLINE(), pTargetPlot->getY_INLINE()) > airRange())
{
return false;
}
if (pTargetPlot->isOwned())
{
if (!potentialWarAction(pTargetPlot))
{
return false;
}
}
pCity = pTargetPlot->getPlotCity();
if (pCity != NULL)
{
if (!(pCity->isBombardable(this)))
{
return false;
}
}
else
{
if (pTargetPlot->getImprovementType() == NO_IMPROVEMENT)
{
return false;
}
if (GC.getImprovementInfo(pTargetPlot->getImprovementType()).isPermanent())
{
return false;
}
if (GC.getImprovementInfo(pTargetPlot->getImprovementType()).getAirBombDefense() == -1)
{
return false;
}
}
return true;
}
bool CvUnit::airBomb(int iX, int iY)
{
CvCity* pCity;
CvPlot* pPlot;
CvWString szBuffer;
if (!canAirBombAt(plot(), iX, iY))
{
return false;
}
pPlot = GC.getMapINLINE().plotINLINE(iX, iY);
if (!isEnemy(pPlot->getTeam()))
{
getGroup()->groupDeclareWar(pPlot, true);
}
if (!isEnemy(pPlot->getTeam()))
{
return false;
}
if (interceptTest(pPlot))
{
return true;
}
pCity = pPlot->getPlotCity();
if (pCity != NULL)
{
pCity->changeDefenseModifier(-airBombCurrRate());
szBuffer = gDLL->getText("TXT_KEY_MISC_YOU_DEFENSES_REDUCED_TO", pCity->getNameKey(), pCity->getDefenseModifier(false), getNameKey());
gDLL->getInterfaceIFace()->addMessage(pCity->getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_BOMBARDED", MESSAGE_TYPE_INFO, getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pCity->getX_INLINE(), pCity->getY_INLINE(), true, true);
szBuffer = gDLL->getText("TXT_KEY_MISC_ENEMY_DEFENSES_REDUCED_TO", getNameKey(), pCity->getNameKey(), pCity->getDefenseModifier(false));
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_BOMBARD", MESSAGE_TYPE_INFO, NULL, (ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), pCity->getX_INLINE(), pCity->getY_INLINE());
}
else
{
if (pPlot->getImprovementType() != NO_IMPROVEMENT)
{
if (GC.getGameINLINE().getSorenRandNum(airBombCurrRate(), "Air Bomb - Offense") >=
GC.getGameINLINE().getSorenRandNum(GC.getImprovementInfo(pPlot->getImprovementType()).getAirBombDefense(), "Air Bomb - Defense"))
{
szBuffer = gDLL->getText("TXT_KEY_MISC_YOU_UNIT_DESTROYED_IMP", getNameKey(), GC.getImprovementInfo(pPlot->getImprovementType()).getTextKeyWide());
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_PILLAGE", MESSAGE_TYPE_INFO, getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), pPlot->getX_INLINE(), pPlot->getY_INLINE());
if (pPlot->isOwned())
{
szBuffer = gDLL->getText("TXT_KEY_MISC_YOU_IMP_WAS_DESTROYED", GC.getImprovementInfo(pPlot->getImprovementType()).getTextKeyWide(), getNameKey(), getVisualCivAdjective(pPlot->getTeam()));
gDLL->getInterfaceIFace()->addMessage(pPlot->getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_PILLAGED", MESSAGE_TYPE_INFO, getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pPlot->getX_INLINE(), pPlot->getY_INLINE(), true, true);
}
pPlot->setImprovementType((ImprovementTypes)(GC.getImprovementInfo(pPlot->getImprovementType()).getImprovementPillage()));
}
else
{
szBuffer = gDLL->getText("TXT_KEY_MISC_YOU_UNIT_FAIL_DESTROY_IMP", getNameKey(), GC.getImprovementInfo(pPlot->getImprovementType()).getTextKeyWide());
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_BOMB_FAILS", MESSAGE_TYPE_INFO, getButton(), (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pPlot->getX_INLINE(), pPlot->getY_INLINE());
}
}
}
setReconPlot(pPlot);
setMadeAttack(true);
changeMoves(GC.getMOVE_DENOMINATOR());
if (pPlot->isActiveVisible(false))
{
CvAirMissionDefinition kAirMission;
kAirMission.setMissionType(MISSION_AIRBOMB);
kAirMission.setUnit(BATTLE_UNIT_ATTACKER, this);
kAirMission.setUnit(BATTLE_UNIT_DEFENDER, NULL);
kAirMission.setDamage(BATTLE_UNIT_DEFENDER, 0);
kAirMission.setDamage(BATTLE_UNIT_ATTACKER, 0);
kAirMission.setPlot(pPlot);
kAirMission.setMissionTime(GC.getMissionInfo((MissionTypes)MISSION_AIRBOMB).getTime() * gDLL->getSecsPerTurn());
gDLL->getEntityIFace()->AddMission(&kAirMission);
}
if (isSuicide())
{
kill(true);
}
return true;
}
I don't think I need to edit the first function at all. But should I check in the second fuction if the plot has route? This is just a ques but would it look something like this:
Spoiler :
Code:
bool CvUnit::canAirBombAt(const CvPlot* pPlot, int iX, int iY) const
{
CvCity* pCity;
CvPlot* pTargetPlot;
if (!canAirBomb(pPlot))
{
return false;
}
pTargetPlot = GC.getMapINLINE().plotINLINE(iX, iY);
if (plotDistance(pPlot->getX_INLINE(), pPlot->getY_INLINE(), pTargetPlot->getX_INLINE(), pTargetPlot->getY_INLINE()) > airRange())
{
return false;
}
if (pTargetPlot->isOwned())
{
if (!potentialWarAction(pTargetPlot))
{
return false;
}
}
pCity = pTargetPlot->getPlotCity();
if (pCity != NULL)
{
if (!(pCity->isBombardable(this)))
{
return false;
}
}
else
{
[COLOR="Red"]/*************************************************************************************************/
/**Can bombard routes 5/12/09 NotSoGood */
/** */
/** */
/*************************************************************************************************/
if (pTargetPlot->getRouteType() == NO_ROUTE)
{
return false:
}
/*************************************************************************************************/
/**Can bombard routes END */
/*************************************************************************************************/[/COLOR]
if (pTargetPlot->getImprovementType() == NO_IMPROVEMENT)
{
return false;
}
if (GC.getImprovementInfo(pTargetPlot->getImprovementType()).isPermanent())
{
return false;
}
if (GC.getImprovementInfo(pTargetPlot->getImprovementType()).getAirBombDefense() == -1)
{
return false;
}
}
return true;
}