I recently made a small change to the startgame, where all units, before "Enable Open Borders" is researched by Writing, are AlwaysHostile.
if ((!m_pUnitInfo->isAlwaysHostile()) && (GET_TEAM(GC.getGameINLINE().getActiveTeam()).isOpenBordersTrading()))
While it works pretty sweet, it have 1 drawback. When an alwaysHostile enters a city it is no longer AlwaysHostile, which in turn ejects the unit from the city and to outside borders.
I would like the unit to not be able to enter the city as long te two civs are at peace, but cant really figure out a good way....
I thought about using CvUnit::canEnterArea. Something like:
if Peace && !openborders && plotIsCity return false. Makes sense? syntax?
if (NULL != pPlot && pPlot->isCity(true, getTeam())) && !(GET_TEAM(getTeam()).isOpenBorders(eTeam)) && (GET_TEAM(getTeam()).isFriendlyTerritory(eTeam))
ps. because its possible to make peace, just removing the isCityCheck in isAlwaysHostile isnt a viable solution, as then all units would be able to attack.
edit:
Thinking the best way would prolly be not to kick units outside of borders before openborderstrading...
cant find the code that kicks units out though...
edit.
or make a declare war check before entering...?
edit.
or only make units alwayshostile outside cultural borders? though if its made in CvUnit::isAlwaysHostile i expect the problem to remain: unit walks into border, unit is no longer AH, unit gets kicked, unit walks into border again.
EDIT.
Make units always hostile outside borders, but able to enter borders before Enable Open Borders.
edit:
Tried to exclude alwayshostile when entering friendly borders, but nothing happened
CvUnit::isAlwaysHostile
eidt : I added the "Before Enable open borders" check to FriendlyTerritory in , and it seems to have fixed it. So
CvGameCoreDLL\CvUnit.cpp
and CvGameCoreDLL\CvTeam.cpp
Edit : A slight change to check if territory is not No_Team
if ((!m_pUnitInfo->isAlwaysHostile()) && (GET_TEAM(GC.getGameINLINE().getActiveTeam()).isOpenBordersTrading()))
While it works pretty sweet, it have 1 drawback. When an alwaysHostile enters a city it is no longer AlwaysHostile, which in turn ejects the unit from the city and to outside borders.
I would like the unit to not be able to enter the city as long te two civs are at peace, but cant really figure out a good way....
I thought about using CvUnit::canEnterArea. Something like:
if Peace && !openborders && plotIsCity return false. Makes sense? syntax?
if (NULL != pPlot && pPlot->isCity(true, getTeam())) && !(GET_TEAM(getTeam()).isOpenBorders(eTeam)) && (GET_TEAM(getTeam()).isFriendlyTerritory(eTeam))
ps. because its possible to make peace, just removing the isCityCheck in isAlwaysHostile isnt a viable solution, as then all units would be able to attack.
edit:
Thinking the best way would prolly be not to kick units outside of borders before openborderstrading...
cant find the code that kicks units out though...
edit.
or make a declare war check before entering...?
edit.
or only make units alwayshostile outside cultural borders? though if its made in CvUnit::isAlwaysHostile i expect the problem to remain: unit walks into border, unit is no longer AH, unit gets kicked, unit walks into border again.
EDIT.
Make units always hostile outside borders, but able to enter borders before Enable Open Borders.
edit:
Tried to exclude alwayshostile when entering friendly borders, but nothing happened
CvUnit::isAlwaysHostile
PHP:
TeamTypes eTeam = plot()->getTeam();
if (GET_TEAM(getTeam()).isFriendlyTerritory(eTeam))
{
return false;
}
eidt : I added the "Before Enable open borders" check to FriendlyTerritory in , and it seems to have fixed it. So
CvGameCoreDLL\CvUnit.cpp
PHP:
bool CvUnit::isAlwaysHostile(const CvPlot* pPlot) const
{
if ((!m_pUnitInfo->isAlwaysHostile()) && (GET_TEAM(GC.getGameINLINE().getActiveTeam()).isOpenBordersTrading())) //Vincentz Always war without openborders enabled
{
return false;
}
if (NULL != pPlot && pPlot->isCity(true, getTeam())) //&& (GET_TEAM(GC.getGameINLINE().getActiveTeam()).isOpenBordersTrading()))
{
return false;
}
//Vincentz Always War start
TeamTypes eTeam = plot()->getTeam();
if (GET_TEAM(getTeam()).isFriendlyTerritory(eTeam))
{
return false;
}
//Vincentz Always War end
return true;
}
and CvGameCoreDLL\CvTeam.cpp
PHP:
bool CvTeam::isFriendlyTerritory(TeamTypes eTeam) const
{
if (eTeam == NO_TEAM)
{
return false;
}
if (eTeam == getID())
{
return true;
}
if (GET_TEAM(eTeam).isVassal(getID()))
{
return true;
}
if (isVassal(eTeam) && isOpenBorders(eTeam))
{
return true;
}
if ((!(eTeam == NO_TEAM)) && (!(GET_TEAM(GC.getGameINLINE().getActiveTeam()).isOpenBordersTrading()))) //Vincentz Openbordersbefore writing
{
return true;
}
Edit : A slight change to check if territory is not No_Team