Annoying Camera movement on Animal Units

jcikal

The Voice of Reason
Joined
Jul 23, 2005
Messages
303
I want to eliminate the game from moving the camera to the animal units whenever they move (Lion, Bear units). Everytime either a lion or bear move, the camera centers on them. How can I tell the game to avoid doing that? Thanks
 
What controls the camera from going to where the animal unit is everytime the animal moves? Where in the python code can I find this? I've looked thru the Camera file but didn't see anything in particular for it. I just want to be able to tell the program to stop centering the camera on the animal unit whenever the animal moves.
 
Looks like an SDK job. Note that since animals are barbarians, and barbarians are always enemies, having the "SHOW_ENEMY_MOVES" option on will mean this function returns true, and thus the camera will point whenever an animal moves. You could turn off the SHOW_ENEMY_MOVES option and the animals won't be zoomed to. Of course, then the non-animal barbarians and other enemies won't be shown either.

To make it so that JUST the animals will not be included in the zoom, trying this in the SDK. In CvSelectionGroup::continueMission...

Code:
if ((getNumUnits() > 0) && (headMissionQueueNode() != NULL))
{
	if (bAction)
	{
		if (bDone || !canAllMove())
		{
			if (plot()->isVisibleToWatchingHuman())
			{
				updateMissionTimer(iSteps);
				getHeadUnit()->ExecuteMove(((float)(getMissionTimer() * gDLL->getMillisecsPerTurn())) / 1000.0f);
				if (GC.getGameINLINE().showAllMoves(getTeam()))
				{
					if (GC.getGameINLINE().getActivePlayer() != NO_PLAYER)
					{
						if (getOwnerINLINE() != GC.getGameINLINE().getActivePlayer())
						{
							if (plot()->isActiveVisible(false))
							{
								[b]// Check for animals here.[/b]
								gDLL->getInterfaceIFace()->lookAt(plot()->getPoint(), CAMERALOOKAT_NORMAL);
							}
						}
					}
				}
			}
		}
	}
}

You would have to go through the selection group and ensure that there is at least one non-animal in it. If there is, then let it do the camera look-at. Otherwise, don't let it do it. So, for example, where I emboldened the text above, you would replace it with...

Code:
[b]if (!isPackOfAnimals())
{[/b]
	gDLL->getInterfaceIFace()->lookAt(plot()->getPoint(), CAMERALOOKAT_NORMAL);
[b]}[/b]

Of course, you would have to make a function inside CvSelectionGroup called "isPackOfAnimals" that returns true if every unit is an animal, something like:

Code:
CvSelectionGroup::isPackOfAnimals() const
{
	CLLNode<IDInfo>* pUnitNode;
	CvUnit* pLoopUnit;

	pUnitNode = headUnitNode();

	while (pUnitNode != NULL)
	{
		pLoopUnit = ::getUnit(pUnitNode->m_data);
		pUnitNode = nextUnitNode(pUnitNode);

		if (!pLoopUnit->isAnimal())
		{
			return false;
		}
	}

	return true;
}

I haven't tried any of this code, but hopefully it puts you on the right track.
 
Thanks Gerikes, I'll try it tonight and let you know if it worked or not.
 
Back
Top Bottom