hi experts,
i am trying to make a mod where seeunits can move on rivers (rivermasks). It actually works, including river-side-cities producing seeunits. Now I am trying to make the units stick to the flow of the river and not being able to take shortcuts by going diagonal (so basically only allowing the units to go north, east, west and south and not northeast etc.). Can someone give me a hint on how to do this? This is what I got (in "unitcanmoveinto" at cvUnit.cpp):
I was thinking about adding something like this:
if (pPlot->isRiverMask() == true || pPlot->isFriendlyCity(*this, true))
{
if (plotDirection == DIRECTION_NORTH)
{
return true;
}
if (plotDirektion == DIRECTION_SOUTHEAST)
{
return false;
} //etc.
break;
}
but i dont know how to get that direction. And I am not sure, if that would actually work, if then the program would understand to take the longer path via south and then east. (forgive my poor english, hope you can still understand what I mean...)
Any ideas for this?
i am trying to make a mod where seeunits can move on rivers (rivermasks). It actually works, including river-side-cities producing seeunits. Now I am trying to make the units stick to the flow of the river and not being able to take shortcuts by going diagonal (so basically only allowing the units to go north, east, west and south and not northeast etc.). Can someone give me a hint on how to do this? This is what I got (in "unitcanmoveinto" at cvUnit.cpp):
Spoiler :
switch (getDomainType())
{
case DOMAIN_SEA:
// River Mod start
if (pPlot->isRiverMask() == true || pPlot->isFriendlyCity(*this, true))
{
return true;
break;
}
else
{
//River Mod end
if (!pPlot->isWater() && !canMoveAllTerrain())
{
if (!pPlot->isFriendlyCity(*this, true) ||!pPlot->isCoastalLand())
{
return false;
}
}
}
break;
{
case DOMAIN_SEA:
// River Mod start
if (pPlot->isRiverMask() == true || pPlot->isFriendlyCity(*this, true))
{
return true;
break;
}
else
{
//River Mod end
if (!pPlot->isWater() && !canMoveAllTerrain())
{
if (!pPlot->isFriendlyCity(*this, true) ||!pPlot->isCoastalLand())
{
return false;
}
}
}
break;
I was thinking about adding something like this:
Spoiler :
if (pPlot->isRiverMask() == true || pPlot->isFriendlyCity(*this, true))
{
if (plotDirection == DIRECTION_NORTH)
{
return true;
}
if (plotDirektion == DIRECTION_SOUTHEAST)
{
return false;
} //etc.
break;
}
but i dont know how to get that direction. And I am not sure, if that would actually work, if then the program would understand to take the longer path via south and then east. (forgive my poor english, hope you can still understand what I mean...)
Any ideas for this?
