The Great Apple said:Lots of people have asked for something similar, but I don't know if anything has been done yet. You'd need to have a play in the SDK to get it working properly I believe - though you may be able to do it in python.
It'll probably mess up the AI pathfinding if you set the limit too low.
bool CvUnit::canJoinGroup(const CvPlot* pPlot, CvSelectionGroup* pSelectionGroup) const
{
CvUnit* pHeadUnit;
if (pSelectionGroup->getOwnerINLINE() == NO_PLAYER)
{
pHeadUnit = pSelectionGroup->getHeadUnit();
if (pHeadUnit != NULL)
{
if (pHeadUnit->getOwnerINLINE() != getOwnerINLINE())
{
return false;
}
}
}
else
{
if (pSelectionGroup->getOwnerINLINE() != getOwnerINLINE())
{
return false;
}
}
if (pSelectionGroup->getNumUnits() > 0)
{
if (!(pSelectionGroup->atPlot(pPlot)))
{
return false;
}
if (pSelectionGroup->getDomainType() != getDomainType())
{
return false;
}
if(pSelectionGroup->getNumUnits() >= 10) // Dale: Max of 10 units per stack
{
return false;
}
}
return true;
}
bool CvSelectionGroup::canMoveInto(CvPlot* pPlot, bool bAttack)
{
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
[B]if (pPlot->getNumUnits() > 10)
{
return false;[/B]
}
if (getNumUnits() > 0)
{
pUnitNode = headUnitNode();
while (pUnitNode != NULL)
{
pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
if (!(pLoopUnit->canMoveInto(pPlot, bAttack)))
{
return false;
}
}
return true;
}
return false;
}
bool CvUnit::canMoveInto(const CvPlot* pPlot, bool bAttack, bool bDeclareWar, bool bIgnoreLoad) const
{
TeamTypes ePlotTeam;
FAssertMsg(pPlot != NULL, "Plot is not assigned a valid value");
if (atPlot(pPlot))
{
return false;
}
if (pPlot->isImpassable())
{
if (!canMoveImpassable())
{
return false;
}
}
[B]if (pPlot->getNumUnits() > 10)
{
return false;[/B]
}
...
...
if (!bAttack)
{
if (pPlot->getNumUnits() > 10)
{
return false;
}
}
Very good point... although again you could make exceptions in the code for this.Zurai said:It would also make cities impossible to defend. Attackers would be gauranteed that there would be no more than X defenders possible, which would make it easy to plan for overwhelming attacks. It would also drastically decrease the value of artillery and air power.
The Great Apple said:*mutters something rude about TheLopez not following Firaxis coding style and missing out curly brackets*
the point is a fight of two stacks of 50 is boring...force fights of armies of 10 moving in fronts will be niceZurai said:It would also make cities impossible to defend. Attackers would be gauranteed that there would be no more than X defenders possible, which would make it easy to plan for overwhelming attacks. It would also drastically decrease the value of artillery and air power.
the point is that a fight of two stacks of 50 is boring... and will force a more complex battlesDale said:TheLopez's code while neat does not cover all situations. There are many situations where canMoveInto is not called, thus the check placed there is useless. City builds, air rebasing, combat (uses "canAdvance" not "canMoveInto"), etc. Also, canMoveInto does not take into account cargo on ships etc.
My example covers all the points raised above by the others. By limiting the stack it leaves the tile open to other players, it is not affected by combat and covers situations where canMoveInto is not called. The AI also uses "canJoinGroup" so it covers the AI as well.
To be honest, I don't see the point of limiting the total number of units in a tile. You block the tile off for non-enemy players, as mentioned it stuffs up city defense, and I bet it'd play havac on auto-workers. Also, what happens in a city if the max units is there and then you build another? Are fighters on a carrier included in the limit? Or units on a transport? Makes naval invasions useless. Also, allies units on the tile too. Another thing that the human can use as a MASSIVE exploit, in canMoveInto it includes stealth units, so if there is 5 units in a tile and you can only move another 4 in, someone has a stealth unit there. Not a good situation at all.
Thus I gave the example of limiting a stack. A neater method for sure without the debilitating effects of limiting the actual tile itself.
Dale
betto212 said:the point is that a fight of two stacks of 50 is boring... and will force a more complex battles
Couldn't you then just have 5 stacks of 10?Dale said:Hence why I said limit the stack, not the tile.![]()
my idea is 5 stacks of 10 but in diferent tiles... the main idea is force tatical moves like protect artilery ou make a barrier for stop enemy advance ...with a unlimited number of unit in a tile the big attaks are unstopable...Shqype said:Couldn't you then just have 5 stacks of 10?
yeah the limiting of units force strategy like defend your cite before the invaders be near the city center ,in real world if the invaders hit the doors of the city center that means that invading squad is winningShqype said:Well, for my Eastern European Battles mod, I planned on implementing a tile limit for all tiles EXCEPT cities. The goal is to diversify city attacks and to prevent super-large stacks of 20 and above. The 10 limit would have been ideal for me. This means that the absolute maximum number of units that could attack a city per turn is 80.
12Monkeys, I have a request for you for CIV4CCP!
Could you implement such a system that limits the amount of units on a non-city tile? I believe the way would be like this:
Allow an option (preferably in GlobalDefines.xml) for each terrain type that has a "space amount," or the amount of space available on each tile for that terrain. By default, you might want to set it to -1 so that there is no limit unless someone actually wants one.
Then, in the CIV4UnitInfos.xml allow a new XML tag <i[TERRAIN]Space> which will define the amount of space the unit takes up. For example, let's say that each plot of land has a maximum of 10 space, then the "space values" of all the units on that plot of land are added up and allowed so long as the number does not exceed the limit (10).
So, regular army units could take up 1 space, for instance, but then you could get heavy artillery which takes up 2 spaces, etc, etc. Maybe later on a tank could take up 3 space.
You could set the default value to 1 so that it wouldn't break any mods already out there; coupled with the -1 default value for the terrain limit this wouldn't hurt at all.
But, it would add a greater depth to the game as far as strategy is concerned. If you made the space limits by terrain type and not domain type, then you could fit much more units in open space (plains) than you can in hills or forest, for instance. This would really protect civilizations with their cities deep in forests or hills because less enemy military units will be able to attack them per turn (because of the terrain tile limit), instead of the way it currently is in CIV 4: if enemy units are on a jungle tile outside of your city, they actually get a defense bonus which only aids their conquest against you, not hinders it!
Shqype said:Well, for my Eastern European Battles mod, I planned on implementing a tile limit for all tiles EXCEPT cities. The goal is to diversify city attacks and to prevent super-large stacks of 20 and above. The 10 limit would have been ideal for me. This means that the absolute maximum number of units that could attack a city per turn is 80.
12Monkeys, I have a request for you for CIV4CCP!
Could you implement such a system that limits the amount of units on a non-city tile? I believe the way would be like this:
Allow an option (preferably in GlobalDefines.xml) for each terrain type that has a "space amount," or the amount of space available on each tile for that terrain. By default, you might want to set it to -1 so that there is no limit unless someone actually wants one.
Then, in the CIV4UnitInfos.xml allow a new XML tag <i[TERRAIN]Space> which will define the amount of space the unit takes up. For example, let's say that each plot of land has a maximum of 10 space, then the "space values" of all the units on that plot of land are added up and allowed so long as the number does not exceed the limit (10).
So, regular army units could take up 1 space, for instance, but then you could get heavy artillery which takes up 2 spaces, etc, etc. Maybe later on a tank could take up 3 space.
You could set the default value to 1 so that it wouldn't break any mods already out there; coupled with the -1 default value for the terrain limit this wouldn't hurt at all.
But, it would add a greater depth to the game as far as strategy is concerned. If you made the space limits by terrain type and not domain type, then you could fit much more units in open space (plains) than you can in hills or forest, for instance. This would really protect civilizations with their cities deep in forests or hills because less enemy military units will be able to attack them per turn (because of the terrain tile limit), instead of the way it currently is in CIV 4: if enemy units are on a jungle tile outside of your city, they actually get a defense bonus which only aids their conquest against you, not hinders it!