MegalodonShark
Chieftain
I have a unit. The unit needs to be immobile. The problem is, the unit is built in a city and needs to get where it's going to be immobile at. This may seem odd, but it is the case. It will remain where it's placed permanently, until destroyed or deleted. The solution to making the unit immobile, but still allowing it to do things on its tile is to assign it "DOMAIN_IMMOBILE" which is easy enough. However, DOMAIN_IMMOBILE prevents paradrops.
I did a search to find where the attributes of DOMAIN_IMMOBILE are defined, and I found in the CvGameCoreUtils.cpp there's a function called "pathDestValid":
In the function, there is a line of code:
Earlier on in the same file, there is "getMissionTypeString"
And in that function I found:
case MISSION_PARADROP: szString = L"MISSION_PARADROP"; break;
So, my question becomes this, since I only know enough to know what I'm looking at, and not really to change it. How do I change the if statement that tests for validity with DOMAIN_IMMOBILE so that it makes an exception if the mission is a paradrop?
----------------
Additional Request: I've successfully set up a working SDK environment and compiled a working dll Just need to find out the code now.
I did a search to find where the attributes of DOMAIN_IMMOBILE are defined, and I found in the CvGameCoreUtils.cpp there's a function called "pathDestValid":
Spoiler :
Code:
int pathDestValid(int iToX, int iToY, const void* pointer, FAStar* finder)
{
PROFILE_FUNC();
CLLNode<IDInfo>* pUnitNode1;
CLLNode<IDInfo>* pUnitNode2;
CvSelectionGroup* pSelectionGroup;
CvUnit* pLoopUnit1;
CvUnit* pLoopUnit2;
CvPlot* pToPlot;
bool bAIControl;
bool bValid;
pToPlot = GC.getMapINLINE().plotSorenINLINE(iToX, iToY);
FAssert(pToPlot != NULL);
pSelectionGroup = ((CvSelectionGroup *)pointer);
if (pSelectionGroup->atPlot(pToPlot))
{
return TRUE;
}
if (pSelectionGroup->getDomainType() == DOMAIN_IMMOBILE)
{
return FALSE;
}
bAIControl = pSelectionGroup->AI_isControlled();
if (bAIControl)
{
if (!(gDLL->getFAStarIFace()->GetInfo(finder) & MOVE_IGNORE_DANGER))
{
if (!(pSelectionGroup->canFight()) && !(pSelectionGroup->alwaysInvisible()))
{
if (GET_PLAYER(pSelectionGroup->getHeadOwner()).AI_getPlotDanger(pToPlot) > 0)
{
return FALSE;
}
}
}
if (pSelectionGroup->getDomainType() == DOMAIN_LAND)
{
int iGroupAreaID = pSelectionGroup->getArea();
if (pToPlot->getArea() != iGroupAreaID)
{
if (!(pToPlot->isAdjacentToArea(iGroupAreaID)))
{
return FALSE;
}
}
}
}
if (bAIControl || pToPlot->isRevealed(pSelectionGroup->getHeadTeam(), false))
{
if (pSelectionGroup->isAmphibPlot(pToPlot))
{
pUnitNode1 = pSelectionGroup->headUnitNode();
while (pUnitNode1 != NULL)
{
pLoopUnit1 = ::getUnit(pUnitNode1->m_data);
pUnitNode1 = pSelectionGroup->nextUnitNode(pUnitNode1);
if ((pLoopUnit1->getCargo() > 0) && (pLoopUnit1->domainCargo() == DOMAIN_LAND))
{
bValid = false;
pUnitNode2 = pLoopUnit1->plot()->headUnitNode();
while (pUnitNode2 != NULL)
{
pLoopUnit2 = ::getUnit(pUnitNode2->m_data);
pUnitNode2 = pLoopUnit1->plot()->nextUnitNode(pUnitNode2);
if (pLoopUnit2->getTransportUnit() == pLoopUnit1)
{
if (pLoopUnit2->isGroupHead())
{
if (pLoopUnit2->getGroup()->canMoveOrAttackInto(pToPlot, (pSelectionGroup->AI_isDeclareWar(pToPlot) || (gDLL->getFAStarIFace()->GetInfo(finder) & MOVE_DECLARE_WAR))))
{
bValid = true;
break;
}
}
}
}
if (bValid)
{
return TRUE;
}
}
}
return FALSE;
}
else
{
if (!(pSelectionGroup->canMoveOrAttackInto(pToPlot, (pSelectionGroup->AI_isDeclareWar(pToPlot) || (gDLL->getFAStarIFace()->GetInfo(finder) & MOVE_DECLARE_WAR)))))
{
return FALSE;
}
}
}
return TRUE;
}
In the function, there is a line of code:
Code:
if (pSelectionGroup->getDomainType() == DOMAIN_IMMOBILE)
{
return FALSE;
}
Earlier on in the same file, there is "getMissionTypeString"
Spoiler :
Code:
void getMissionTypeString(CvWString& szString, MissionTypes eMissionType)
{
switch (eMissionType)
{
case NO_MISSION: szString = L"NO_MISSION"; break;
case MISSION_MOVE_TO: szString = L"MISSION_MOVE_TO"; break;
case MISSION_ROUTE_TO: szString = L"MISSION_ROUTE_TO"; break;
case MISSION_MOVE_TO_UNIT: szString = L"MISSION_MOVE_TO_UNIT"; break;
case MISSION_SKIP: szString = L"MISSION_SKIP"; break;
case MISSION_SLEEP: szString = L"MISSION_SLEEP"; break;
case MISSION_FORTIFY: szString = L"MISSION_FORTIFY"; break;
case MISSION_PLUNDER: szString = L"MISSION_PLUNDER"; break;
case MISSION_AIRPATROL: szString = L"MISSION_AIRPATROL"; break;
case MISSION_SEAPATROL: szString = L"MISSION_SEAPATROL"; break;
case MISSION_HEAL: szString = L"MISSION_HEAL"; break;
case MISSION_SENTRY: szString = L"MISSION_SENTRY"; break;
case MISSION_AIRLIFT: szString = L"MISSION_AIRLIFT"; break;
case MISSION_NUKE: szString = L"MISSION_NUKE"; break;
case MISSION_RECON: szString = L"MISSION_RECON"; break;
case MISSION_PARADROP: szString = L"MISSION_PARADROP"; break;
case MISSION_AIRBOMB: szString = L"MISSION_AIRBOMB"; break;
case MISSION_BOMBARD: szString = L"MISSION_BOMBARD"; break;
case MISSION_PILLAGE: szString = L"MISSION_PILLAGE"; break;
case MISSION_SABOTAGE: szString = L"MISSION_SABOTAGE"; break;
case MISSION_DESTROY: szString = L"MISSION_DESTROY"; break;
case MISSION_STEAL_PLANS: szString = L"MISSION_STEAL_PLANS"; break;
case MISSION_FOUND: szString = L"MISSION_FOUND"; break;
case MISSION_SPREAD: szString = L"MISSION_SPREAD"; break;
case MISSION_SPREAD_CORPORATION: szString = L"MISSION_SPREAD_CORPORATION"; break;
case MISSION_JOIN: szString = L"MISSION_JOIN"; break;
case MISSION_CONSTRUCT: szString = L"MISSION_CONSTRUCT"; break;
case MISSION_DISCOVER: szString = L"MISSION_DISCOVER"; break;
case MISSION_HURRY: szString = L"MISSION_HURRY"; break;
case MISSION_TRADE: szString = L"MISSION_TRADE"; break;
case MISSION_GREAT_WORK: szString = L"MISSION_GREAT_WORK"; break;
case MISSION_INFILTRATE: szString = L"MISSION_INFILTRATE"; break;
case MISSION_GOLDEN_AGE: szString = L"MISSION_GOLDEN_AGE"; break;
case MISSION_BUILD: szString = L"MISSION_BUILD"; break;
case MISSION_LEAD: szString = L"MISSION_LEAD"; break;
case MISSION_ESPIONAGE: szString = L"MISSION_ESPIONAGE"; break;
case MISSION_DIE_ANIMATION: szString = L"MISSION_DIE_ANIMATION"; break;
case MISSION_BEGIN_COMBAT: szString = L"MISSION_BEGIN_COMBAT"; break;
case MISSION_END_COMBAT: szString = L"MISSION_END_COMBAT"; break;
case MISSION_AIRSTRIKE: szString = L"MISSION_AIRSTRIKE"; break;
case MISSION_SURRENDER: szString = L"MISSION_SURRENDER"; break;
case MISSION_CAPTURED: szString = L"MISSION_CAPTURED"; break;
case MISSION_IDLE: szString = L"MISSION_IDLE"; break;
case MISSION_DIE: szString = L"MISSION_DIE"; break;
case MISSION_DAMAGE: szString = L"MISSION_DAMAGE"; break;
case MISSION_MULTI_SELECT: szString = L"MISSION_MULTI_SELECT"; break;
case MISSION_MULTI_DESELECT: szString = L"MISSION_MULTI_DESELECT"; break;
default: szString = CvWString::format(L"UNKOWN_MISSION(%d)", eMissionType); break;
}
}
And in that function I found:
case MISSION_PARADROP: szString = L"MISSION_PARADROP"; break;
So, my question becomes this, since I only know enough to know what I'm looking at, and not really to change it. How do I change the if statement that tests for validity with DOMAIN_IMMOBILE so that it makes an exception if the mission is a paradrop?
----------------
Additional Request: I've successfully set up a working SDK environment and compiled a working dll Just need to find out the code now.