#include "stdafx.h"
#include "Global_variables_extern.h"
#include "Basics_functions.h"
#include "Vampirism_fire.h"
#include "HumanTactics.h"

bool fSetFlagUnit(IdDataUnit *pIdDataUnit,ParamPlayer *pParamPlayer)
{
	bool vFalgResult = FALSE;
	if (pIdDataUnit->pDataUnit && (unsigned int)pIdDataUnit->pDataUnit != 0xdddddddd)
	{
		if (pIdDataUnit->pDataUnit->Zdanie == TRUE)
		{
			HRECT vRect;
			real vX,vY;
			integer vParentKey;
			integer vStop;
			vStop = 0;
			vParentKey = GetExpiredTimer();
			vX = GetUnitX(pIdDataUnit->pDataUnit->WhichUnit);
			vY = GetUnitY(pIdDataUnit->pDataUnit->WhichUnit);
			switch(pIdDataUnit->pDataUnit->vId)
			{
			case ID_UNIT_BUILD_DOM:
			case ID_UNIT_BUILD_LESOPILKA1:
			case ID_UNIT_BUILD_LESOPILKA2:
				vRect = NULL;
				vRect = vMapBases.fFindRectForHouse(vX,vY,pIdDataUnit->pDataUnit->vIdDataUnit);
				if (vRect == NULL)
				{
					vRect = Rect(vX-128*2,vY+128*2,vX+128*2,vY-128*2);
				}
				if (vRect != NULL)
				{
					SaveReal(vHT,vParentKey,CONST_HUNIT_HOUSE_X,vX);
					SaveReal(vHT,vParentKey,CONST_HUNIT_HOUSE_Y,vY);
					SaveReal(vHT,vParentKey,CONST_HUNIT_HOUSE_G,0);
					EnumDestructablesInRect(vRect,NULL,&fFlagAction);
					pParamPlayer->fAddTree(LoadDestructableHandle(vHT,vParentKey,CONST_HDESTRUCTABLE_TREE));
					if (IssueTargetOrderById(pIdDataUnit->pDataUnit->WhichUnit,
											 ID_ORDER_SMART,
											 LoadDestructableHandle(vHT,vParentKey,CONST_HDESTRUCTABLE_TREE)) == TRUE)
					{
						pIdDataUnit->pDataUnit->Flag = TRUE;
					}
					RemoveRect(vRect);
				}
				break;
			}
			vStop = 1;
			if (vStop == 1)
			{
				vFalgResult = TRUE;
			}
		}
	}
	return vFalgResult;
}

HDESTRUCTABLE fNearestTree(DataUnit *pDataUnit,ParamPlayer *pParamPlayer)
{
	if (pDataUnit == NULL) return 0;
	int vvi;
	real vX,vY;
	real vX_D,vY_D;
	real vG1, vG2;
	HDESTRUCTABLE vDest;
	vDest = NULL;
	vX = GetUnitX(pDataUnit->WhichUnit);
	vY = GetUnitY(pDataUnit->WhichUnit);
	vG2 = 0;
	for (vvi = 0; vvi < pParamPlayer->MAX_NAMBER_OF_TREES; vvi++)
	{
		if (pParamPlayer->vTree[vvi] != 0)
		{
			vX_D = GetDestructableX(pParamPlayer->vTree[vvi]);
			vY_D = GetDestructableY(pParamPlayer->vTree[vvi]);
			vG1 = sqrtf(powf(abs(vX_D - vX),2)+powf(abs(vY_D - vY),2));
			if (vG2 > vG1 || vG2 == 0)
			{
				vG2 = vG1;
				vDest = pParamPlayer->vTree[vvi];
			}
		}
	}
	return vDest;
}

// Атакую стаком
bool fStackAttack(HumanPlayer *pHumanPlayer, ActionStackForUnits* vStackAttack, integer vId)
{
	if (vStackAttack == NULL) return FALSE;
	if (vId == 0) return FALSE;
	pHumanPlayer->pDataUnit = pDataHumans->vActionStackForUnitsEnemy.fGetDataUnit(COMMENT_NEW_UNIT,vId);
	if (pHumanPlayer->pDataUnit == NULL) return FALSE;
	StackForUnits *current;
	pHumanPlayer->vFlagAttack = FALSE;
	current = vStackAttack->first;
	while (current && (unsigned int)current != 0xdddddddd)
	{
		if (current->vIdDataUnit2.pDataUnit && (unsigned int)current->vIdDataUnit2.pDataUnit != 0xdddddddd)
		{
			if (GetUnitTypeId(current->vIdDataUnit2.pDataUnit->WhichUnit) != 0)
			{
				pHumanPlayer->pDataUnit = pDataHumans->vActionStackForUnitsEnemy.fGetDataUnit(COMMENT_NEW_UNIT,current->vIdDataUnit2.pDataUnit,vId);
				if (pHumanPlayer->pDataUnit != NULL)
				{
					if (IssueTargetOrderById(current->vIdDataUnit2.pDataUnit->WhichUnit,
											 ID_ORDER_ATTACK,
											 pHumanPlayer->pDataUnit->WhichUnit) == TRUE)
					{
						current->vIdDataUnit2.pDataUnit->TargetUnit = pHumanPlayer->pDataUnit->WhichUnit;
						current->vIdDataUnit2.pDataUnit->Atakuet = TRUE;
						pHumanPlayer->vFlagAttack = TRUE;
					}
				}
			}
			else
			{
				fAddDataUnitInRange(pHumanPlayer,current->vIdDataUnit2.pDataUnit);
			}
		}
		current = current->next;
	}
	return pHumanPlayer->vFlagAttack;
}

bool fTowersAttack(HumanPlayer *pHumanPlayer, integer vId)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (vId == 0) return FALSE;
	pHumanPlayer->pDataUnit = pDataHumans->vActionStackForUnitsEnemy.fGetDataUnit(COMMENT_NEW_UNIT,vId);
	if (pHumanPlayer->pDataUnit == NULL) return FALSE;
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments != COMMENT_MAIN_WALL) return FALSE;
	pHumanPlayer->vX_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->LastCoordinates.X;
	pHumanPlayer->vY_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->LastCoordinates.Y;
	pHumanPlayer->vX_2 = pHumanPlayer->pDataUnit->LastCoordinatesForEnemy.X;
	pHumanPlayer->vY_2 = pHumanPlayer->pDataUnit->LastCoordinatesForEnemy.Y;
	pHumanPlayer->vG = fG(pHumanPlayer->vX_1,pHumanPlayer->vY_1,pHumanPlayer->vX_2,pHumanPlayer->vY_2);
	if (pHumanPlayer->vG > 128*8) return FALSE;
	pHumanPlayer->vFlagAttackTowers = FALSE;
	StackForUnits *current;
	//pDataUnit = pHumanPlayer->vActionStackForUnits.fGetDataUnit(ID_UNIT_WORKER,ID_ORDER_WAITING);
	// Управляю пушками
		current = pHumanPlayer->vActionStackForUnitsTower.first;
		while (current && (unsigned int)current != 0xdddddddd)
		{
			if (1)
			{
				if (current->vIdDataUnit2.pDataUnit && (unsigned int)current->vIdDataUnit2.pDataUnit != 0xdddddddd)
				{
					if (fIsFirstTower(current->vIdDataUnit2.pDataUnit->vId))
					{
						if (GetUnitTypeId(current->vIdDataUnit2.pDataUnit->WhichUnit) != 0)
						{
							pHumanPlayer->vIdOrder = GetUnitCurrentOrder(current->vIdDataUnit2.pDataUnit->WhichUnit);
							pHumanPlayer->vId = GetUnitTypeId(current->vIdDataUnit2.pDataUnit->TargetUnit);
							if (pHumanPlayer->vIdOrder != ID_ORDER_ATTACK ||
								pHumanPlayer->vId != vId)
							{
								if (IssueTargetOrderById(current->vIdDataUnit2.pDataUnit->WhichUnit,
														 ID_ORDER_ATTACK,
														 pHumanPlayer->pDataUnit->WhichUnit) == TRUE)
								{
									pHumanPlayer->vFlagAttackTowers = TRUE;
								}
							}
						}
						else
						{
							fAddDataUnitInRange(pHumanPlayer,current->vIdDataUnit2.pDataUnit);
						}
					}
				}
			}
			current = current->next;
		}
	return pHumanPlayer->vFlagAttackTowers;
}

void fWorkers(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return;
	if (pHumanPlayer->vBlockCreateWorkers == TRUE) return;
	StackForUnits *current;
	//pDataUnit = pHumanPlayer->vActionStackForUnits.fGetDataUnit(ID_UNIT_WORKER,ID_ORDER_WAITING);
	// Смартю деревья рабочим
	if (pHumanPlayer->vTimeAttackWorker == 0 ||
		(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeAttackWorker > 20))
	{
		current = pHumanPlayer->vActionStackForUnitsWorkers.first;
		while (current && (unsigned int)current != 0xdddddddd)
		{
			if (current->vIdDataUnit2.pDataUnit && (unsigned int)current->vIdDataUnit2.pDataUnit != 0xdddddddd)
			{
				if (current->vIdDataUnit2.pDataUnit->vId == ID_UNIT_WORKER)
				{
					if (GetUnitTypeId(current->vIdDataUnit2.pDataUnit->WhichUnit) != 0)
					{
						pHumanPlayer->vIdOrder = GetUnitCurrentOrder(current->vIdDataUnit2.pDataUnit->WhichUnit);
						if (pHumanPlayer->vIdOrder == ID_ORDER_WAITING)
						{
							if (IssueTargetOrderById(current->vIdDataUnit2.pDataUnit->WhichUnit,
														ID_ORDER_SMART,
														fNearestTree(current->vIdDataUnit2.pDataUnit,&pHumanPlayer->vParamPlayer)) == TRUE)
							{
								current->vIdDataUnit2.pDataUnit->Harvest = TRUE;
							}
						
						}
					}
					else
					{
						fAddDataUnitInRange(pHumanPlayer,current->vIdDataUnit2.pDataUnit);
					}
				}
			}
			current = current->next;
		}
	}
	pHumanPlayer->vQ = 0;
	if (pHumanPlayer->vQWorkers != 0 &&
		pHumanPlayer->vQWorkers > pHumanPlayer->vActionStackForUnitsWorkers.vQNewUnit &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed > 3 * 60)
	{
m3:
		pHumanPlayer->vQWorkersCurrent = pHumanPlayer->vActionStackForUnitsWorkers.vQNewUnit;
		/*if (pHumanPlayer->vCurrentEra == 0 &&
			((pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeAttackWorker > 21) ||
			pHumanPlayer->vTimeAttackWorker == 0))*/
		if (pHumanPlayer->vActionStackForUnitsWorkers.vQNewUnit < 48)
		{
			pHumanPlayer->vQ = 0;
			current = pHumanPlayer->vActionStackForUnitsWorkers.first;
			while (current)
			{
				if (current->vIdDataUnit2.pDataUnit == NULL)
				{
					pHumanPlayer->vActionStackForUnitsWorkers.fFreeStackForUnits(current->vIdDataUnit2.vId);
				}
				if (pHumanPlayer->vBase.vShaman == FALSE)
				{
					if (current->vIdDataUnit2.pDataUnit &&
						pHumanPlayer->vBase.vShaman == FALSE &&
						fFindBaseByDataUnit(current->vIdDataUnit2.pDataUnit) != 0 &&
						fRemotenessBase(current->vIdDataUnit2.pDataUnit) > 5)
					{
						pHumanPlayer->vBase.vShaman = TRUE;
						pHumanPlayer->vBase.vInt3_Shaman = current->vIdDataUnit2.pDataUnit->vPosHarvesting;
					}
				}
				if (pHumanPlayer->vBase.vShaman == TRUE &&
					current->vIdDataUnit2.pDataUnit &&
					fFindBaseByDataUnit(current->vIdDataUnit2.pDataUnit) != 0)
				{
					if (GetUnitTypeId(current->vIdDataUnit2.pDataUnit->WhichUnit) != 0)
					{
						if (IssuePointOrderById(current->vIdDataUnit2.pDataUnit->WhichUnit,
												ID_ORDER_DETONATE,
												GetUnitX(current->vIdDataUnit2.pDataUnit->WhichUnit),
												GetUnitY(current->vIdDataUnit2.pDataUnit->WhichUnit)) == TRUE)
						{
							if (pHumanPlayer->vBase.vFullWorkers == TRUE) pHumanPlayer->vBase.vFullWorkers = FALSE;
							pHumanPlayer->vTimeAttackWorker = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
							pHumanPlayer->vDelWorkers = TRUE;
							pHumanPlayer->vQ++;
						}
					}
					else
					{
						fAddDataUnitInRange(pHumanPlayer,current->vIdDataUnit2.pDataUnit);
					}
					//if (pHumanPlayer->vQ >= 10) return;
				}
				current = current->next;
			}
		}
		if (pHumanPlayer->vQ > 0 &&
			pHumanPlayer->vQWorkersCurrent != pHumanPlayer->vActionStackForUnitsWorkers.vQNewUnit) goto m3;
	}
m1:
	if (pHumanPlayer->vActionStackForUnitsWorkers.vQNewUnit >= 0)
	{
		pHumanPlayer->vQWorkersCurrent = pHumanPlayer->vActionStackForUnitsWorkers.vQNewUnit;
		pHumanPlayer->vQ = 0;
		current = pHumanPlayer->vActionStackForUnitsWorkers.first;
		while (current && (unsigned int)current != 0xdddddddd)
		{
			if (current->vIdDataUnit2.pDataUnit && (unsigned int)current->vIdDataUnit2.pDataUnit != 0xdddddddd)
			{
				pHumanPlayer->vIdOrder = GetUnitCurrentOrder(current->vIdDataUnit2.pDataUnit->WhichUnit);
				pHumanPlayer->vMaxLife = GetUnitState(current->vIdDataUnit2.pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE);
				pHumanPlayer->vLife = GetUnitState(current->vIdDataUnit2.pDataUnit->WhichUnit, UNIT_STATE_LIFE);
				if (current->vIdDataUnit2.pDataUnit->vId == ID_UNIT_WORKER &&
					//(fFindBaseByDataUnitNoEnemy(current->vIdDataUnit2.pDataUnit) == 0 ||
					//!(pHumanPlayer->vIdOrder == ID_ORDER_SMART ||
					//pHumanPlayer->vIdOrder == ID_ORDER_HARVEST) &&
					((pHumanPlayer->vMaxLife - pHumanPlayer->vLife) >= 10))//)
				{
					if (GetUnitTypeId(current->vIdDataUnit2.pDataUnit->WhichUnit) != 0)
					{
						if (IssuePointOrderById(current->vIdDataUnit2.pDataUnit->WhichUnit,
												ID_ORDER_DETONATE,
												GetUnitX(current->vIdDataUnit2.pDataUnit->WhichUnit),
												GetUnitY(current->vIdDataUnit2.pDataUnit->WhichUnit)) == TRUE)
						{
							pHumanPlayer->vTimeAttackWorker = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
							if (pHumanPlayer->vBase.vFullWorkers == TRUE) pHumanPlayer->vBase.vFullWorkers = FALSE;
							pHumanPlayer->vDelWorkers = TRUE;
							pHumanPlayer->vQ++;
						}
					}
					else
					{
						fAddDataUnitInRange(pHumanPlayer,current->vIdDataUnit2.pDataUnit);
					}
					//if (pHumanPlayer->vQ >= 10) return;
										//current->vIdDataUnit2.pDataUnit->LastCoordinates.X,
										//current->vIdDataUnit2.pDataUnit->LastCoordinates.Y);
					//return;
					//pHumanPlayer->vBase.vFullWorkers = FALSE;
				}
			}
			current = current->next;
		}
	}
	else
	{
		goto m2;
	}
	if (pHumanPlayer->vQ > 0 &&
		pHumanPlayer->vQWorkersCurrent != pHumanPlayer->vActionStackForUnitsWorkers.vQNewUnit) goto m1;
	if (pHumanPlayer->vDelWorkers == TRUE &&
		pHumanPlayer->vCurrentEra == 0 &&
		((pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeAttackWorker > 20) ||
		pHumanPlayer->vTimeAttackWorker == 0))
	{
		pHumanPlayer->vDelWorkers = FALSE;
	}
m2:;
	if (pHumanPlayer->vDelWorkers == FALSE &&
		pHumanPlayer->vCurrentEra == 0 &&
		((pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeAttackWorker > 20) ||
		pHumanPlayer->vTimeAttackWorker == 0))
	{
		pHumanPlayer->vBase.vShaman = FALSE;
		if (pHumanPlayer->vActionStackForUnitsWorkers.fGetQuantityUnits(ID_UNIT_WORKER) < 48)
		{
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].vIdForComments == COMMENT_FIRST_DOM)
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].pDataUnit,ID_UNIT_WORKER,1);
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_DOM].vIdForComments == COMMENT_SECOND_DOM)
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_DOM].pDataUnit,ID_UNIT_WORKER,1);
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_DOM].vIdForComments == COMMENT_THIRD_DOM)
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_DOM].pDataUnit,ID_UNIT_WORKER,1);
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_DOM].vIdForComments == COMMENT_FOURTH_DOM)
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_DOM].pDataUnit,ID_UNIT_WORKER,1);
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIFTH_DOM].vIdForComments == COMMENT_FIFTH_DOM)
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIFTH_DOM].pDataUnit,ID_UNIT_WORKER,1);
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_SIXTH_DOM].vIdForComments == COMMENT_SIXTH_DOM)
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_SIXTH_DOM].pDataUnit,ID_UNIT_WORKER,1);			
		}
		else
		{
			pHumanPlayer->vBase.vFullWorkers = TRUE;
		}
	}
	pHumanPlayer->vQWorkers = pHumanPlayer->vActionStackForUnitsWorkers.vQNewUnit;
}

void fFurbolgs(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return;
	StackForUnits *current;
	// Смартю деревья урсам
	current = pHumanPlayer->vActionStackForUnitsFurbolgs.first;
	if (pHumanPlayer->vTimeAttackWorker == 0 ||
		pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeAttackWorker > 20)
	while (current && (unsigned int)current != 0xdddddddd)
	{
		if (current->vIdDataUnit2.pDataUnit && (unsigned int)current->vIdDataUnit2.pDataUnit != 0xdddddddd)
		{
			if (current->vIdDataUnit2.pDataUnit->vId == ID_UNIT_URSA)
			{
				if (GetUnitTypeId(current->vIdDataUnit2.pDataUnit->WhichUnit) != 0)
				{
					pHumanPlayer->vIdOrder = GetUnitCurrentOrder(current->vIdDataUnit2.pDataUnit->WhichUnit);
					if (pHumanPlayer->vIdOrder == ID_ORDER_WAITING &&
						current->vIdDataUnit2.pDataUnit->vHelping == FALSE)
					{
						if (fHarvestingNearestTree(current->vIdDataUnit2.pDataUnit) == TRUE)
						{
							current->vIdDataUnit2.pDataUnit->Harvest = TRUE;
						}
						
					}
				}
				else
				{
					fAddDataUnitInRange(pHumanPlayer,current->vIdDataUnit2.pDataUnit);
				}
			}
		}
		current = current->next;
	}
	current = pHumanPlayer->vActionStackForUnitsFurbolgs.first;
	while (current)
	{
		if (current->vIdDataUnit2.pDataUnit)
		{
			if (current->vIdDataUnit2.pDataUnit->vId == ID_UNIT_URSA &&
				current->vIdDataUnit2.pDataUnit->Atakovan == TRUE)
			{
				pHumanPlayer->vTimeAttackWorker = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
				if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_HEAL_1].vIdForComments == COMMENT_HEAL_1)
				{
					IssuePointOrderById(current->vIdDataUnit2.pDataUnit->WhichUnit,
										ID_ORDER_BLINK,
										pHumanPlayer->vParamPlayer.vUnit[COMMENT_HEAL_1].pDataUnit->LastCoordinates.X,
										pHumanPlayer->vParamPlayer.vUnit[COMMENT_HEAL_1].pDataUnit->LastCoordinates.Y);
				}
			}
		}
		current = current->next;
	}
}

bool fBuildHealTower(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vFlagBuildHeal == FALSE &&
		pHumanPlayer->vFlagRepair == TRUE &&
		pHumanPlayer->vStageRepairWall == 0 &&
		GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.8))
	{
		pHumanPlayer->vFlagBuildHeal = TRUE;
		pHumanPlayer->vStageBuildHeal = 0;
		return TRUE;
	}
	if (pHumanPlayer->vFlagBuildHeal == TRUE)
	switch(pHumanPlayer->vStageBuildHeal)
	{
	case 0:
		pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_TOWER_HEAL_LVL1,0,40,TRUE,FALSE,FALSE);
		if (pHumanPlayer->vInt3 != vSizeMap)
		{
			pHumanPlayer->vStageBuildHeal++;
		}
		else
		{
		}
		goto m1;
	case 1:
		if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_BLINK) == 1)
			pHumanPlayer->vStageBuildHeal++;
		goto m1;
	case 2:
		if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_TOWER_HEAL_LVL1) == 1)
			pHumanPlayer->vStageBuildHeal++;
		goto m1;
	case 3:
		if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_TOWER_HEAL_LVL1,COMMENT_HEAL_1) == true)
			pHumanPlayer->vStageBuildHeal++;
		goto m1;
	case 4:
		pHumanPlayer->vFlagBuildHeal = FALSE;
		pHumanPlayer->vStageBuildHeal = 0;
		goto m1;
	}
	return FALSE;
m1:
	return TRUE;
}

bool fDelChainByN(HumanPlayer *pHumanPlayer, unsigned short vN)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (vN < 0) return FALSE;
	sStackChains *vCurrentChain = pHumanPlayer->vCurrentChain;
	sStackChains *vNextChain = NULL;
	sStackChains *vForerunnerChain = NULL;
	while (vCurrentChain)
	{
		vNextChain = vCurrentChain->vNext;
		if (vCurrentChain && vCurrentChain->vN == vN)
		{
			if (vForerunnerChain)
			{
				vForerunnerChain->vNext = vNextChain;
				if (vNextChain == NULL)
				{
					pHumanPlayer->vLastChain = vForerunnerChain;
				}
			}
			else
			{
				if (vNextChain)
				{
					pHumanPlayer->vCurrentChain = vNextChain;
				}
				else
				{
					if (pHumanPlayer->vCurrentChain == vCurrentChain &&
						pHumanPlayer->vLastChain == vCurrentChain)
					{
						pHumanPlayer->vCurrentChain = NULL;
						pHumanPlayer->vLastChain = NULL;
					}
				}
			}
			vCurrentChain->vNext = NULL;
			//free(vCurrentChain->vName);
			delete[] vCurrentChain->vName;
			vCurrentChain->vName = NULL;
			//free(vCurrentChain);
			//delete vCurrentChain;
			vCurrentChain->vId = 0;
			return TRUE;
		}
		vForerunnerChain = vCurrentChain;
		vCurrentChain = vNextChain;
	}
	return FALSE;
}

unsigned short fFindFreeNChain(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return NO_CHAIN;
	//unsigned short vN;
	/*if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vN >= 1)
	{
		return pHumanPlayer->vCurrentChain->vN - 1;
	}*/
	//else
	for (unsigned short vvi = NO_CHAIN - 2; vvi > 0; vvi--)
	{
		if (pHumanPlayer->vMassChains[vvi] == FALSE)
		{
			//vN = pHumanPlayer->vNFree;
			//pHumanPlayer->vNFree++;
			return vvi;
		}
	}
	return NO_CHAIN;
}

bool fNewChainActionBuild(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vComment, integer vId, unsigned short vCommentUnit, char *vText)
{
	if (pHumanPlayer == NULL) return FALSE;
	return fNewChain(pHumanPlayer,vBoolCurrentChain,vN,CHAIN_NO_UNIVERSAL_STAGE,CHAIN_ACTION_BUILD,vComment,vId,vCommentUnit,0,FALSE,0,vText);
}

bool fNewChainActionTrain(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, integer vId, unsigned short vQTrain, bool vMandatoryTrain, unsigned short vCommentUnit, char *vText)
{
	if (pHumanPlayer == NULL) return FALSE;
	return fNewChain(pHumanPlayer,vBoolCurrentChain,vN,CHAIN_NO_UNIVERSAL_STAGE,CHAIN_ACTION_TRAIN,0,vId,vCommentUnit,0,vMandatoryTrain,vQTrain,vText);
}

bool fNewChainActionResearch(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vNResearch, unsigned short vCommentUnit, char *vText)
{
	if (pHumanPlayer == NULL) return FALSE;
	return fNewChain(pHumanPlayer,vBoolCurrentChain,vN,CHAIN_NO_UNIVERSAL_STAGE,CHAIN_ACTION_RESEARCH,0,0,vCommentUnit,vNResearch,FALSE,0,vText);
}

bool fNewChainActionUpgrade(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, integer vId, unsigned short vCommentUnit, char *vText)
{
	if (pHumanPlayer == NULL) return FALSE;
	return fNewChain(pHumanPlayer,vBoolCurrentChain,vN,CHAIN_NO_UNIVERSAL_STAGE,CHAIN_ACTION_UPGRADE,0,vId,vCommentUnit,0,FALSE,0,vText);
}

bool fNewChainActionSetFlagToNearestTree(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vCommentUnit, char *vText)
{
	if (pHumanPlayer == NULL) return FALSE;
	return fNewChain(pHumanPlayer,vBoolCurrentChain,vN,CHAIN_NO_UNIVERSAL_STAGE,CHAIN_ACTION_SET_FLAG_TO_NEREST_TREE,0,0,vCommentUnit,0,FALSE,0,vText);
}

bool fNewChainActionToWaitResearch(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vNResearch, char *vText)
{
	if (pHumanPlayer == NULL) return FALSE;
	return fNewChain(pHumanPlayer,vBoolCurrentChain,vN,CHAIN_NO_UNIVERSAL_STAGE,CHAIN_ACTION_TO_WAIT_RESEARCH,0,0,0,vNResearch,FALSE,0,vText);
}

bool fNewChainActionToWaitBuild(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vCommentUnit, char *vText)
{
	if (pHumanPlayer == NULL) return FALSE;
	return fNewChain(pHumanPlayer,vBoolCurrentChain,vN,CHAIN_NO_UNIVERSAL_STAGE,CHAIN_ACTION_TO_WAIT_BUILD,0,0,vCommentUnit,0,FALSE,0,vText);
}

bool fNewChainActionUniversal(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vStage, char *vText)
{
	if (pHumanPlayer == NULL) return FALSE;
	return fNewChain(pHumanPlayer,vBoolCurrentChain,vN,vStage,CHAIN_ACTION_UNIVERSAL,0,0,0,0,FALSE,0,vText);
}

bool fNewChainAction(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vAction, char *vText)
{
	if (pHumanPlayer == NULL) return FALSE;
	return fNewChain(pHumanPlayer,vBoolCurrentChain,vN,CHAIN_NO_UNIVERSAL_STAGE,vAction,0,0,0,0,FALSE,0,vText);
}

// Поиск свободного номера в стаке цепочек
unsigned short fFindFreeNInStackChains()
{
	if (vNLastStackChains == NO_UNIT)
	{
		vNLastStackChains = 0;
		return vNLastStackChains;
	}
	if (vNLastStackChains >= 0 && vNLastStackChains < MAX_COUNT_UNITS)
	{
		if (vNLastStackChains + 1 < MAX_COUNT_UNITS)
		{
			vNLastStackChains++;
			return vNLastStackChains;
		}
		for (unsigned short vvi = vNLastStackChains; vvi >= 0; vvi--)
		{
			if (vStackChains[vvi].vId == 0)
			{
				vNLastStackChains = vvi;
			}
			else
			{
				if (vvi == vNLastStackChains)
				{
					break;
				}
				else
				{
					return vNLastStackChains;
				}
			}
			if (vvi == 0) break;
		}
		for (unsigned short vvi = 0; vvi < vNLastStackChains; vvi++)
		{
			if (vStackChains[vvi].vId == 0)
			{
				return vvi;
			}
		}
	}
	return LIMIT_UNIT;
}

bool fNewChain(HumanPlayer *pHumanPlayer, bool vBoolCurrentChain, unsigned short vN, unsigned short vStage, unsigned short vAction, unsigned short vComment,
	           integer vId, unsigned short vCommentUnit, unsigned short vNResearch, bool vMandatoryTrain, unsigned short vQTrain, char *vText)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (vN < 0 || vStage < 0 || vAction < 0 || vComment < 0 || vId < 0 || vCommentUnit < 0 || vNResearch < 0 || vQTrain < 0) return FALSE;
	/*if (pHumanPlayer->vCurrentChain &&
		vText &&
		strlen(vText) == strlen(pHumanPlayer->vCurrentChain->vName) &&
		memcmp(pHumanPlayer->vCurrentChain->vName,vText,strlen(pHumanPlayer->vCurrentChain->vName)) == 0)
	{
		return FALSE;
	}*/
	sStackChains *vNewChain;
	//vNewChain = (sStackChains*) malloc(sizeof(sStackChains));
	//vNewChain = new struct sStackChains;
	unsigned short vNInStackChains;
	vNewChain = NULL;
	vNInStackChains = fFindFreeNInStackChains();
	if (vNInStackChains < 0 || vNInStackChains >= MAX_COUNT_UNITS) return FALSE;
	vNewChain = &vStackChains[vNInStackChains];
	vNewChain->vN = vN;
	vNewChain->vStage = vStage;
	vNewChain->vAction = vAction;
	vNewChain->vComment = vComment;
	vNewChain->vId = vId;
	vNewChain->vCommentUnit = vCommentUnit;
	vNewChain->vNResearch = vNResearch;
	vNewChain->vMandatoryTrain = vMandatoryTrain;
	vNewChain->vQTrain = vQTrain;
	vNewChain->vComplite = FALSE;
	//vNewChain->vName = (char*) malloc(sizeof(char)*strlen(vText)+1);
	vNewChain->vName = new char[strlen(vText)+1];
	sprintf(vNewChain->vName,"%s\0",vText);
	vNewChain->vNext = NULL;
	vNewChain->vForerunner = NULL;
	vNewChain->pHumanPlayer = pHumanPlayer;
	if (vN > pHumanPlayer->MAX_Q_FOR_MASS_CHAINS - 500 && vN <= pHumanPlayer->MAX_Q_FOR_MASS_CHAINS - 1)
	{
		pHumanPlayer->vMassChains[vN] = TRUE;
	}
	if (vBoolCurrentChain == TRUE)//Если добавляем в начало цепочки
	{
		if (pHumanPlayer->vCurrentChain)
		{
			vNewChain->vNext = pHumanPlayer->vCurrentChain;
			pHumanPlayer->vCurrentChain = vNewChain;
			if (pHumanPlayer->vLastChain == NULL)
			{
				pHumanPlayer->vLastChain = pHumanPlayer->vCurrentChain;
			}
		}
		else
		{
			if (pHumanPlayer->vCurrentChain == NULL &&
				pHumanPlayer->vLastChain == NULL)
			{
				pHumanPlayer->vCurrentChain = vNewChain;
				pHumanPlayer->vLastChain = vNewChain;
			}
		}
	}
	else//Если добавляем в конец цепочки
	{
		if (pHumanPlayer->vLastChain)
		{
			vNewChain->vForerunner = pHumanPlayer->vLastChain;
			pHumanPlayer->vLastChain->vNext = vNewChain;
			pHumanPlayer->vLastChain = vNewChain;
			if (pHumanPlayer->vCurrentChain == NULL)
			{
				pHumanPlayer->vCurrentChain = pHumanPlayer->vLastChain;
			}
		}
		else
		{
			if (pHumanPlayer->vCurrentChain == NULL &&
				pHumanPlayer->vLastChain == NULL)
			{
				pHumanPlayer->vCurrentChain = vNewChain;
				pHumanPlayer->vLastChain = vNewChain;
			}
		}
	}
	if (pHumanPlayer->vCurrentChain &&
		pHumanPlayer->vParamPlayer.vStage != pHumanPlayer->vCurrentChain->vStage)
	{
		pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentChain->vStage;
		pHumanPlayer->vStage = pHumanPlayer->vCurrentChain->vStage;
	}
	if (pHumanPlayer->vCurrentChain)
	{
		if (vBoolCurrentChain == TRUE)
		{
			pHumanPlayer->vCurrentChain->vTimer = TRUE;
		}
		else
		{
			pHumanPlayer->vCurrentChain->vTimer = FALSE;
		}
		if (pHumanPlayer->vCurrentChain->vTimer == TRUE)
		{
			pHumanPlayer->vCurrentChain->vTime = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
		}
	}
	return TRUE;
}

// Удалить все цепочки от текущей цепочки
bool fFreeAllChains(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	sStackChains *vNextChain = NULL;
	while (pHumanPlayer->vCurrentChain)
	{
		vNextChain = pHumanPlayer->vCurrentChain->vNext;
		//free(pHumanPlayer->vCurrentChain->vName);
		delete[] pHumanPlayer->vCurrentChain->vName;
		pHumanPlayer->vCurrentChain->vName = NULL;
		pHumanPlayer->vCurrentChain->vNext = NULL;
		//free(pHumanPlayer->vCurrentChain);
		//delete pHumanPlayer->vCurrentChain;
		pHumanPlayer->vCurrentChain->vId = 0;
		pHumanPlayer->vCurrentChain->pHumanPlayer = NULL;
		pHumanPlayer->vCurrentChain = vNextChain;
	}
	pHumanPlayer->vCurrentChain = NULL;
	pHumanPlayer->vLastChain = NULL;
	return TRUE;
}

// Удалить все цепочки игрока
bool fDelAllChainsPlayer(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	sStackChains *vChain = NULL;
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < MAX_COUNT_UNITS; pHumanPlayer->vvi++)
	{
		if (//pHumanPlayer->vCurrentChain->vId != 0 &&
			vStackChains[pHumanPlayer->vvi].pHumanPlayer == pHumanPlayer)
		{
			vChain = &vStackChains[pHumanPlayer->vvi];
			delete[] vChain->vName;
			vChain->vName = NULL;
			vChain->vNext = NULL;
			vChain->pHumanPlayer = NULL;
			vChain->vId = 0;
		}
	}
	pHumanPlayer->vCurrentChain = NULL;
	pHumanPlayer->vLastChain = NULL;
	return TRUE;
}

// Добавить цепочку
bool fAddChain(HumanPlayer *pHumanPlayer, sStackChains* vChainAdding)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (vChainAdding == NULL) return FALSE;
	sStackChains *vCurrentChain = vChainAdding;
	while (vCurrentChain)
	{
		if (vCurrentChain->vNext == NULL) break;
		vCurrentChain = vCurrentChain->vNext;
	}
	if (pHumanPlayer->vCurrentChain)
	{
		vCurrentChain->vNext = pHumanPlayer->vCurrentChain;
		pHumanPlayer->vCurrentChain->vForerunner = vCurrentChain;
		pHumanPlayer->vCurrentChain = vChainAdding;
	}
	else
	{
		if (pHumanPlayer->vCurrentChain == NULL &&
			pHumanPlayer->vLastChain == NULL)
		{
			pHumanPlayer->vCurrentChain = vChainAdding;
			pHumanPlayer->vLastChain = vCurrentChain;
		}
	}
	return TRUE;
}

// Сдвиг цепочки с последнего номера к определённому номеру (после него).
bool fShiftChainLastToN(HumanPlayer *pHumanPlayer, unsigned short vN)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (vN < 0) return FALSE;
	if (pHumanPlayer->vLastChain == NULL) return FALSE;
	sStackChains *vCutChain = NULL;
	vCutChain = fCutChain(pHumanPlayer,pHumanPlayer->vLastChain->vN);
	if (vCutChain == NULL) return FALSE;
	if (fPasteChain(pHumanPlayer,vCutChain,vN) == FALSE)
	{
		return FALSE;
	}
	return TRUE;
}

// Вырезать цепочку по определённому номеру
sStackChains * fCutChain(HumanPlayer *pHumanPlayer, unsigned short vN)
{
	if (pHumanPlayer == NULL) return NULL;
	if (vN < 0) return NULL;
	sStackChains *vCurrentChain = pHumanPlayer->vCurrentChain;
	sStackChains *vForerunnerChain = NULL;
	sStackChains *vNextChain = NULL;
	sStackChains *vCutChain = NULL;
	while (vCurrentChain)
	{
		vNextChain = vCurrentChain->vNext;
		if (vCurrentChain->vN == vN)
		{
			vCutChain = vCurrentChain;
			if (vNextChain)
			{
				if (vForerunnerChain)
				{
					vForerunnerChain->vNext = vNextChain;
					vNextChain->vForerunner = vForerunnerChain;
				}
				else
				{
					vNextChain->vForerunner = NULL;
					pHumanPlayer->vCurrentChain = vNextChain;
					pHumanPlayer->vLastChain = vNextChain;
				}
			}
			else
			{
				if (vForerunnerChain)
				{
					vForerunnerChain->vNext = NULL;
					pHumanPlayer->vLastChain = vForerunnerChain;
				}
				else
				{
					pHumanPlayer->vCurrentChain = NULL;
					pHumanPlayer->vLastChain = NULL;
				}
			}
			return vCutChain;
		}
		vForerunnerChain = vCurrentChain;
		vCurrentChain = vNextChain;
	}
	return NULL;
}

// Вставить цепочку после определенённого номера 
bool fPasteChain(HumanPlayer *pHumanPlayer, sStackChains *vPasteChain, unsigned short vN)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (vN < 0) return FALSE;
	if (vPasteChain == NULL) return FALSE;
	sStackChains *vCurrentChain = pHumanPlayer->vCurrentChain;
	sStackChains *vForerunnerChain = NULL;
	sStackChains *vNextChain = NULL;
	while (vCurrentChain)
	{
		vNextChain = vCurrentChain->vNext;
		if (vCurrentChain->vN == vN && vNextChain && vForerunnerChain)
		{
			//vForerunnerChain->vNext = NULL;
			//vCurrentChain->vForerunner = NULL;
			vCurrentChain->vNext = vPasteChain;
			vNextChain->vForerunner = vPasteChain;
			vPasteChain->vNext = vNextChain;
			return TRUE;
		}
		vForerunnerChain = vCurrentChain;
		vCurrentChain = vNextChain;
	}
	return FALSE;
}

// Сдвиг цепочки до определенного номера и разрыв её.
bool fShiftChain(HumanPlayer *pHumanPlayer, unsigned short vN)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (vN < 0) return FALSE;
	sStackChains *vCurrentChain = pHumanPlayer->vCurrentChain;
	sStackChains *vForerunnerChain = NULL;
	while (vCurrentChain)
	{
		if (vCurrentChain->vN == vN)
		{
			if (vForerunnerChain)
			{
				vForerunnerChain->vNext = NULL;
			}
			vCurrentChain->vForerunner = NULL;
			pHumanPlayer->vCurrentChain = vCurrentChain;
			return TRUE;
		}
		vForerunnerChain = vCurrentChain;
		vCurrentChain = vCurrentChain->vNext;
	}
	return FALSE;
}

// Копирование цепочки.
sStackChains* fCopyChain(HumanPlayer *pHumanPlayer, sStackChains *vChain)
{
	if (pHumanPlayer == NULL) return NULL;
	if (vChain == NULL) return NULL;
	sStackChains *vNewChain;
	unsigned short vNInStackChains;
	vNewChain = NULL;
	vNInStackChains = fFindFreeNInStackChains();
	if (vNInStackChains < 0 || vNInStackChains >= MAX_COUNT_UNITS) return NULL;
	vNewChain = &vStackChains[vNInStackChains];
	vNewChain->vN = vChain->vN;
	vNewChain->vStage = vChain->vStage;
	vNewChain->vAction = vChain->vAction;
	vNewChain->vComment = vChain->vComment;
	vNewChain->vId = vChain->vId;
	vNewChain->vCommentUnit = vChain->vCommentUnit;
	vNewChain->vNResearch = vChain->vNResearch;
	vNewChain->vMandatoryTrain = vChain->vMandatoryTrain;
	vNewChain->vQTrain = vChain->vQTrain;
	vNewChain->vComplite = FALSE;
	//vNewChain->vName = (char*) malloc(sizeof(char)*strlen(vChain->vName)+1);
	if (vChain->vName)
	{
		vNewChain->vName = new char[strlen(vChain->vName)+1];
	}
	else
	{
		vNewChain->vName = vNewChain->vName;
	}
	sprintf(vNewChain->vName,"%s\0",vChain->vName);
	vNewChain->vNext = vChain->vNext;
	vNewChain->vForerunner = vChain->vForerunner;
	vNewChain->pHumanPlayer = pHumanPlayer;
	return vNewChain;
}

// Загрузить текущую цепочку
bool fLoadCurrentChain(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	sStackChains *vNextChain = NULL;
	if (pHumanPlayer->vCurrentChain &&
		((//pHumanPlayer->vCurrentChain->vN < pHumanPlayer->MAX_Q_FOR_MASS_CHAINS - 500 &&
		pHumanPlayer->vMassChains[pHumanPlayer->vCurrentChain->vN] == TRUE) ||
		//(pHumanPlayer->vCurrentChain->vN >= pHumanPlayer->MAX_Q_FOR_MASS_CHAINS - 500 && pHumanPlayer->vMassChains[pHumanPlayer->vCurrentChain->vN] == FALSE) ||
		(pHumanPlayer->vCurrentChain->vTimer == TRUE &&
		(pHumanPlayer->vCurrentChain->vTime == 0 || pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vCurrentChain->vTime > 70)) ||
		(pHumanPlayer->vCurrentChain->vComplite == TRUE) ||
		(pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_UNIVERSAL &&
		pHumanPlayer->vParamPlayer.vStage != pHumanPlayer->vCurrentChain->vStage)))
	{
		if (pHumanPlayer->vCurrentChain->vTimer == TRUE &&
			(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vCurrentChain->vTime > 150))
		{
			pHumanPlayer->vCurrentChain->vTime = pHumanPlayer->vCurrentChain->vTime;
		}
		pHumanPlayer->vForerunnerChainTemp = fCopyChain(pHumanPlayer,pHumanPlayer->vCurrentChain);
		vNextChain = pHumanPlayer->vCurrentChain->vNext;
		//free(pHumanPlayer->vCurrentChain->vName);
		delete[] pHumanPlayer->vCurrentChain->vName;
		pHumanPlayer->vCurrentChain->vName = NULL;
		pHumanPlayer->vCurrentChain->vNext = NULL;
		//free(pHumanPlayer->vCurrentChain);
		if (pHumanPlayer->vCurrentChain->vN != 0 &&
			pHumanPlayer->vCurrentChain->vN == pHumanPlayer->vBase.vNChainForHouseForBlockVampire)
		{
			pHumanPlayer->vBase.vHouseForBlockVampire = TRUE;
		}
		if (pHumanPlayer->vCurrentChain->vN < pHumanPlayer->MAX_Q_FOR_MASS_CHAINS - 500)
		{
			pHumanPlayer->vMassChains[pHumanPlayer->vCurrentChain->vN] = TRUE;
		}
		else
		{
			pHumanPlayer->vMassChains[pHumanPlayer->vCurrentChain->vN] = FALSE;
		}
		pHumanPlayer->vCurrentChain->vId = 0;
		pHumanPlayer->vCurrentChain->pHumanPlayer = NULL;
		//delete pHumanPlayer->vCurrentChain;
		if (vNextChain == NULL)
		{
			vNextChain = vNextChain;
		}
		pHumanPlayer->vCurrentChain = vNextChain;
		if (pHumanPlayer->vCurrentChain)
		{
			pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentChain->vStage;
			return TRUE;
		}
		//else
		//{
		//	pHumanPlayer->vCurrentChain = pHumanPlayer->vCurrentChain;
		//}
	}
	if (pHumanPlayer->vCurrentChain &&
		pHumanPlayer->vCurrentChain->vAction != CHAIN_ACTION_UNIVERSAL &&
		pHumanPlayer->vParamPlayer.vStage >= 300 &&
		pHumanPlayer->vParamPlayer.vStage <= 399)
	{
		return TRUE;
	}
	//if (pHumanPlayer->vCurrentChain && pHumanPlayer->vParamPlayer.vStage == 0)
	//{
	//	return TRUE;
	//}
	if (pHumanPlayer->vCurrentChain)
	{
		pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentChain->vStage;
		return TRUE;
	}
	return FALSE;
}

// Удалить цепочку в стаке действий по номеру
bool fDelChainInStackActions(HumanPlayer *pHumanPlayer, unsigned short vChain)
{
	/*if (pHumanPlayer == NULL) return FALSE;
	if (vChain < 0) return FALSE;
	sStackActions *vCurrent = NULL;
	sStackActions *vFirst = NULL;
	sStackActions *vNext = NULL;
	vCurrent = pHumanPlayer->vCurrentAction;
	while(vCurrent)
	{
		vNext = vCurrent->vNext;
		if (vCurrent && vCurrent->vChain == vChain)
		{
			if (vFirst)
			{
				vFirst->vNext = vNext;
				vFirst = NULL;
			}
			vCurrent->vNext = NULL;
			delete vCurrent;
			//free(vCurrent);
		}
		if (vCurrent && vCurrent->vChain != vChain)
		{
			vFirst = vCurrent;
		}
		vCurrent = vNext;
	}*/
	return TRUE;
}

// Добавить действие в стек действий
bool fAddActionInStackActions(HumanPlayer *pHumanPlayer, unsigned short vStage, bool vBoolCurrent, unsigned short vChain)
{
	/*if (pHumanPlayer == NULL) return FALSE;
	if (vStage < 0) return FALSE;
	if (vChain < 0) return FALSE;
	sStackActions *vCurrent = NULL;
	sStackActions *vLast = NULL;
	sStackActions *vFirst = NULL;
	if (vBoolCurrent == TRUE)
	{
		if (vChain == 0)
		{
			if (pHumanPlayer->vCurrentAction)
			{
				vCurrent = pHumanPlayer->vCurrentAction;
			}
			//vFirst = (sStackActions*) malloc(sizeof(sStackActions));
			vFirst = new struct sStackActions;
			vFirst->vStage = vStage;
			vFirst->vChain = vChain;
			vFirst->vNext = vCurrent;
			pHumanPlayer->vCurrentAction = vFirst;
			if (pHumanPlayer->vLastAction == NULL)
			{
				pHumanPlayer->vLastAction = vFirst;
			}
		}
		else
		{
			if (vBundle)
			{
				if (pHumanPlayer->vCurrentAction)
				{
					vCurrent = pHumanPlayer->vCurrentAction;
				}
				vBundle->vNext = vCurrent;
				if (vBundle->vHeadChain)
				{
					pHumanPlayer->vCurrentAction = vBundle->vHeadChain;
					pHumanPlayer->vParamPlayer.vStage = 0;
				}
				else
				{
					return FALSE;
				}
			}
			else
			{
				return FALSE;
			}
		}
		
	}
	else
	{
		//vLast = (sStackActions*) malloc(sizeof(sStackActions));
		vLast = new struct sStackActions;
		vLast->vStage = vStage;
		vLast->vChain = vChain;
		vLast->vNext = NULL;
		if (vChain == 0)
		{
			if (pHumanPlayer->vCurrentAction == NULL)
			{
				pHumanPlayer->vCurrentAction = vLast;
			}
			if (pHumanPlayer->vLastAction)
			{
				pHumanPlayer->vLastAction->vNext = vLast;
			}
			pHumanPlayer->vLastAction = vLast;
		}
		else
		{
			if (vBundle)
			{
				vLast->vHeadChain = vBundle->vHeadChain;
				vBundle->vNext = vLast;
			}
			else
			{
				vLast->vHeadChain = vLast;
			}
			vBundle = vLast;
		}
	}*/
	return TRUE;
}

// Освободить текущее действие в стеке действий
bool vFreeCurrentActionInStackActions_2(HumanPlayer *pHumanPlayer)
{
	/*if (pHumanPlayer == NULL) return FALSE;
	sStackActions *vNext = NULL;
	// Очищаем стек
	if (pHumanPlayer->vCurrentAction)
	{
		//pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentAction->vNext->vStage;
		vNext = pHumanPlayer->vCurrentAction->vNext;
		pHumanPlayer->vCurrentAction->vNext = NULL;
		//free(pHumanPlayer->vCurrentAction);
		delete pHumanPlayer->vCurrentAction;
		pHumanPlayer->vCurrentAction = vNext;
		if (pHumanPlayer->vCurrentAction == NULL)
		{
			pHumanPlayer->vLastAction = NULL;
		}
	}*/
	return TRUE;
}

// Освободить текущее действие в стеке действий
bool vFreeCurrentActionInStackActions(HumanPlayer *pHumanPlayer)
{
	/*if (pHumanPlayer == NULL) return FALSE;
	sStackActions *vNext = NULL;
	// Очищаем стек
	if (pHumanPlayer->vCurrentAction)
	{
		//if (pHumanPlayer->vParamPlayer.vStage != pHumanPlayer->vForerunnerStage)
		//{
			pHumanPlayer->vForerunnerStage = pHumanPlayer->vCurrentAction->vStage;
			//pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentAction->vStage;
			if (pHumanPlayer->vParamPlayer.vStage == 0)
			{
				pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentAction->vStage;
			}
			if (pHumanPlayer->vParamPlayer.vStage != pHumanPlayer->vCurrentAction->vNext->vStage &&
				pHumanPlayer->vParamPlayer.vStage == pHumanPlayer->vCurrentAction->vStage + 1)
			{
				pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentAction->vNext->vStage;
			}
			if (pHumanPlayer->vCurrentAction->vNext->vStage == pHumanPlayer->vParamPlayer.vStage)
			{
				pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentAction->vNext->vStage;
				vNext = pHumanPlayer->vCurrentAction->vNext;
				pHumanPlayer->vCurrentAction->vNext = NULL;
				//free(pHumanPlayer->vCurrentAction);
				delete pHumanPlayer->vCurrentAction;
				pHumanPlayer->vCurrentAction = vNext;
				if (pHumanPlayer->vCurrentAction == NULL)
				{
					pHumanPlayer->vLastAction = NULL;
				}
			}
		//}
	}*/
	return TRUE;
}

// Маршрутизация цепочек
void fMapRoutingChains(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return;
	if (pHumanPlayer->vFlagDearBase == FALSE)
	{
		return;
	}
	if (fLoadCurrentChain(pHumanPlayer) == TRUE)
	{
		return;
	}
	/*switch (pHumanPlayer->vCurrentEra)
	{
	case 0:
		if (fChainsEra0_New(pHumanPlayer) == TRUE);
		break;
	}
	if (pHumanPlayer->vError == 1)
	{
		pHumanPlayer->vError = 0;
		if (fFreeAllChains(pHumanPlayer) == FALSE)
		{
			return;
		}
	}
	if (pHumanPlayer->vCurrentEra == 0 && pHumanPlayer->vNextEra == 0)
	{
		pHumanPlayer->vNextEra = 1;
		return;
	}
	if (pHumanPlayer->vCurrentEra == 1 && pHumanPlayer->vNextEra == 1)
	{
		pHumanPlayer->vNextEra = 2;
		return;
	}*/
	if (pHumanPlayer->vCurrentEra == 0 && pHumanPlayer->vNextEra == 0 && fChainsEra0_New(pHumanPlayer) == TRUE)
	{
		pHumanPlayer->vNextEra = 1;
		return;
	}
}

bool fChainsEra0_New(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vBase.vSlayerBaze == FALSE)
	{
		pHumanPlayer->vQNumForChains = 60;
		for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < pHumanPlayer->vQNumForChains; pHumanPlayer->vvi++)
		{
			pHumanPlayer->vMassNumForChains[pHumanPlayer->vvi] = (unsigned short)pHumanPlayer->vvi;
		}
	}
	else
	{
		pHumanPlayer->vQNumForChains = 0;
		pHumanPlayer->vvi = 0;
		while (pHumanPlayer->vQNumForChains < 61)
		{
			pHumanPlayer->vMassNumForChains[pHumanPlayer->vQNumForChains] = (unsigned short)pHumanPlayer->vvi;
			pHumanPlayer->vQNumForChains++;
			switch(pHumanPlayer->vvi)
			{
			case 17:
				pHumanPlayer->vvi = 24;
				break;
			case 20:
				if (pHumanPlayer->vFlag2 == 0)
				{
					pHumanPlayer->vvi = 38;
					pHumanPlayer->vFlag2 = 1;
					break;
				}
				if (pHumanPlayer->vFlag2 == 1)
				{
					pHumanPlayer->vvi = 20;
					pHumanPlayer->vFlag2 = 2;
					break;
				}
				if (pHumanPlayer->vFlag2 == 2)
				{
					pHumanPlayer->vvi = 26;
					pHumanPlayer->vFlag2 = 0;
					break;
				}
				break;
			case 23:
				pHumanPlayer->vvi = 31;
				break;
			case 25:
				pHumanPlayer->vvi = 20;
				break;
			case 29:
				pHumanPlayer->vvi = 21;
				break;
			case 30:
				pHumanPlayer->vvi = 33;
				break;
			case 32:
				pHumanPlayer->vvi = 30;
				break;
			case 34:
				pHumanPlayer->vvi = 36;
				break;
			case 37:
				pHumanPlayer->vvi = 40;
				//vSlayerBaze = FALSE;
				break;
			case 39:
				pHumanPlayer->vvi = 60;
				break;
			case 60:
				pHumanPlayer->vvi = 18;
				break;
			default:
				pHumanPlayer->vvi++;
				break;
			}
		}
	}
	pHumanPlayer->vBase.vNChainForHouseForBlockVampire = 60;
	fChains(pHumanPlayer);
	if (pHumanPlayer->vBase.vSlayerBaze == FALSE)
	{
		sprintf(vBuf,"%s\0","Грейдим мейн вал в фиолетовый");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,fFindFreeNChain(pHumanPlayer),ID_UNIT_BUILD_WALL_VIOLET,COMMENT_MAIN_WALL,vBuf) == TRUE);
		fShiftChainLastToN(pHumanPlayer,30);
		sprintf(vBuf,"%s\0","Строим защиту 4 от вампа");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,fFindFreeNChain(pHumanPlayer),COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_4,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
		fShiftChainLastToN(pHumanPlayer,30);
		pHumanPlayer->vBase.vNChainForHouseForBlockVampire = fFindFreeNChain(pHumanPlayer);
		if (pHumanPlayer->vBase.vNChainForHouseForBlockVampire <= 0) goto m24;
		sprintf(vBuf,"%s\0","Строим защиту от вампа");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,pHumanPlayer->vBase.vNChainForHouseForBlockVampire,COMMENT_HOUSE_FOR_BLOCK_VAMPIRE,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
		fShiftChainLastToN(pHumanPlayer,30);
		sprintf(vBuf,"%s\0","Строим защиту 3 от вампа");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,fFindFreeNChain(pHumanPlayer),COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_3,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
		fShiftChainLastToN(pHumanPlayer,30);
		sprintf(vBuf,"%s\0","Строим защиту 2 от вампа");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,fFindFreeNChain(pHumanPlayer),COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_2,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
		fShiftChainLastToN(pHumanPlayer,30);
m24:;
	}
	/*
	if (pHumanPlayer->vCurrentChain)
	{
		if (fFreeAllChains(pHumanPlayer) == FALSE)
		{
			return FALSE;
		}
	}
	// План есть?
	// Двигаемся по 5000 в массиве, ищем пустую ячейку в массиве
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi <= pHumanPlayer->vNCommentLast; pHumanPlayer->vvi++)
	{
		if (pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvi] == MAX_COUNT_UNITS)//Я нахожу 5000(пустую ячейку)
		{
			if (pHumanPlayer->vvi >= 0 && pHumanPlayer->vvi <= COMMENT_UNITS_OLD)//Старые комменты юнитов
			{
				if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi].vIdForComments == pHumanPlayer->vvi)//Если юнит есть такой то берём его в массив и континуе
				{
					pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvi] = pHumanPlayer->vvi;
					continue;
				}
				break;*/
				/*COMMENT_MAIN_HUMAN;
				COMMENT_FIRST_DOM;
				COMMENT_SECOND_DOM;
				COMMENT_THIRD_DOM;
				COMMENT_FOURTH_DOM;
				COMMENT_FIFTH_DOM;
				COMMENT_SIXTH_DOM;
				COMMENT_FIRST_TENT;
				COMMENT_SECOND_TENT;
				COMMENT_THIRD_TENT;
				COMMENT_FOURTH_TENT;
				COMMENT_FIRST_KUZNYA;
				COMMENT_MAIN_WALL;
				COMMENT_SLAYER;
				COMMENT_TAVERN_SLAYER;
				COMMENT_TEMPLE;
				COMMENT_FIRE_1;
				COMMENT_FIRE_2;
				COMMENT_FIRE_3;
				COMMENT_FIRE_4;
				COMMENT_HEAL_1;
				COMMENT_HEAL_2;*/
			/*}
		}
		else//если ячейка в массиве занята
		{
			//проверямем умер ли юнит
			if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvi]].vIdForComments != pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvi])
			{
				// и освобождаем ячейку в массиве
				pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvi] = MAX_COUNT_UNITS;
				break;
			}
		}
	}
	// А остальные ячейки в массиве проверяем, и освобождаем
	for (pHumanPlayer->vvj = pHumanPlayer->vvi + 1; pHumanPlayer->vvj <= pHumanPlayer->vNCommentLast; pHumanPlayer->vvj++)
	{
		if (pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvj] != MAX_COUNT_UNITS)//Не пустая ячейка
		{
			//проверямем умер юнит или нет
			if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvj]].vIdForComments != pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvj])
			{
				// и освобождаем ячейку в массиве
				pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvj] = MAX_COUNT_UNITS;
			}
		}
	}
	// Обнавляем ласт
	for (pHumanPlayer->vvj = pHumanPlayer->vNCommentLast; pHumanPlayer->vvj > 0 ; pHumanPlayer->vvj--)
	{
		if (pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvj] != MAX_COUNT_UNITS)//Не пустая ячейка
		{
			break;
		}
	}
	pHumanPlayer->vNCommentLast = pHumanPlayer->vvj;
	pHumanPlayer->vSlayerBaze = pHumanPlayer->vBase.vSlayerBaze;
	// Улучшения юнитов, специальные действия
	for (pHumanPlayer->vvr = 0; pHumanPlayer->vvr <= pHumanPlayer->vNCommentLast; pHumanPlayer->vvr++)
	{
		pHumanPlayer->vComment = pHumanPlayer->vvr;
		if (pHumanPlayer->vSlayerBaze == FALSE)
		switch (pHumanPlayer->vComment)
		{
		case COMMENT_MAIN_WALL:
			if (fIsMassCommentUnit(pHumanPlayer,pHumanPlayer->vComment) == TRUE)
			{
				//if (pHumanPlayer->vCommentUnitUpgradeLast == 0) pHumanPlayer->vCommentUnitUpgradeLast = COMMENT_FIRST_TENT;
				// Улучшаем 4 тента
				for (pHumanPlayer->vvj = 0; pHumanPlayer->vvj < 4; pHumanPlayer->vvj++)
				{
					switch (pHumanPlayer->vvj)
					{
					case 0: pHumanPlayer->vCommentUnitUpgrade = COMMENT_FIRST_TENT; pHumanPlayer->vIdUpgradeUnit = ID_UNIT_BUILD_TENT; pHumanPlayer->vN = COMMENT_CHAIN_UPGRAGE_TENT; break;
					case 1: pHumanPlayer->vCommentUnitUpgrade = COMMENT_SECOND_TENT; pHumanPlayer->vIdUpgradeUnit = ID_UNIT_BUILD_TENT; pHumanPlayer->vN = COMMENT_CHAIN_UPGRAGE_TENT; break;
					case 2: pHumanPlayer->vCommentUnitUpgrade = COMMENT_THIRD_TENT; pHumanPlayer->vIdUpgradeUnit = ID_UNIT_BUILD_TENT; pHumanPlayer->vN = COMMENT_CHAIN_UPGRAGE_TENT; break;
					case 3: pHumanPlayer->vCommentUnitUpgrade = COMMENT_FOURTH_TENT; pHumanPlayer->vIdUpgradeUnit = ID_UNIT_BUILD_TENT; pHumanPlayer->vN = COMMENT_CHAIN_UPGRAGE_TENT; break;
					}
					if (fIsMassCommentUnit(pHumanPlayer,pHumanPlayer->vCommentUnitUpgrade) == TRUE)//Юнит есть в массиве
					{
						if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCommentUnitUpgrade].vIdForComments == pHumanPlayer->vCommentUnitUpgrade &&//юнит есть
							pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCommentUnitUpgrade].pDataUnit->vId == pHumanPlayer->vIdUpgradeUnit)//Юнит определённого Id
						{
							pHumanPlayer->vCommentUnit = pHumanPlayer->vCommentUnitUpgrade;
							//pHumanPlayer->vCommentUnitUpgradeLast = pHumanPlayer->vCommentUnitUpgrade;
							if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
							return TRUE;
						}
					}
					else
					{
						goto m1;
					}
				}
				if (pHumanPlayer->vNLast == COMMENT_CHAIN_UPGRAGE_TENT)//если мы улучшали тенты
				{
					// Есть 6 домов
					pHumanPlayer->vFlag2 = TRUE;
					for (pHumanPlayer->vvj = 0; pHumanPlayer->vvj < 6; pHumanPlayer->vvj++)
					{
						switch (pHumanPlayer->vvj)
						{
						case 0: pHumanPlayer->vCommentUnit = COMMENT_FIRST_DOM; break;
						case 1: pHumanPlayer->vCommentUnit = COMMENT_SECOND_DOM; break;
						case 2: pHumanPlayer->vCommentUnit = COMMENT_THIRD_DOM; break;
						case 3: pHumanPlayer->vCommentUnit = COMMENT_FOURTH_DOM; break;
						case 4: pHumanPlayer->vCommentUnit = COMMENT_FIFTH_DOM; break;
						case 5: pHumanPlayer->vCommentUnit = COMMENT_SIXTH_DOM; break;
						}
						if (fIsMassCommentUnit(pHumanPlayer,pHumanPlayer->vCommentUnit) == FALSE)//Юнит есть в массиве
						{
							pHumanPlayer->vFlag2 = FALSE;
							break;
						}
					}
					if (pHumanPlayer->vFlag2 == TRUE)
					{
						pHumanPlayer->vN = COMMENT_CHAIN_FULL_WORKERS;
						if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
						return TRUE;
					}
				}
				// Улучашаем вал до фиолетового
				for (pHumanPlayer->vvj = 0; pHumanPlayer->vvj < 2; pHumanPlayer->vvj++)
				{
					switch (pHumanPlayer->vvj)
					{
					case 0: pHumanPlayer->vCommentUnitUpgrade = COMMENT_MAIN_WALL; pHumanPlayer->vIdUpgradeUnit = ID_UNIT_BUILD_WALL_BROWN; pHumanPlayer->vN = COMMENT_CHAIN_UPGRAGE_WALL_YELLOW; break;
					case 1: pHumanPlayer->vCommentUnitUpgrade = COMMENT_MAIN_WALL; pHumanPlayer->vIdUpgradeUnit = ID_UNIT_BUILD_WALL_YELLOW; pHumanPlayer->vN = COMMENT_CHAIN_UPGRAGE_WALL_VIOLET; break;
					}
					if (fIsMassCommentUnit(pHumanPlayer,pHumanPlayer->vCommentUnitUpgrade) == TRUE)//Юнит есть в массиве
					{
						if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCommentUnitUpgrade].vIdForComments == pHumanPlayer->vCommentUnitUpgrade &&//юнит есть
							pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCommentUnitUpgrade].pDataUnit->vId == pHumanPlayer->vIdUpgradeUnit)//Юнит определённого Id
						{
							pHumanPlayer->vCommentUnit = pHumanPlayer->vCommentUnitUpgrade;
							if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
							return TRUE;
						}
					}
					else
					{
						goto m1;
					}
				}
				// Иследования в первой кузне
				pHumanPlayer->vCommentUnit = COMMENT_FIRST_KUZNYA;
				if (fIsMassCommentUnit(pHumanPlayer,pHumanPlayer->vCommentUnit) == TRUE)//Юнит есть в массиве
				{
					pHumanPlayer->vFlag2 = TRUE;
					switch (pHumanPlayer->vNLast)
					{
					case COMMENT_CHAIN_UPGRAGE_WALL_VIOLET:
						pHumanPlayer->vN = COMMENT_CHAIN_RESEARCH_GEM1;
						break;
					default:
						pHumanPlayer->vFlag2 = FALSE;
						break;
					}
					if (pHumanPlayer->vFlag2 == TRUE)
					if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
					if (pHumanPlayer->vFlag2 == TRUE)
						return TRUE;
				}
				// Специальные действия по порядку
				pHumanPlayer->vFlag2 = TRUE;
				switch (pHumanPlayer->vNLast)
				{
				case COMMENT_CHAIN_FULL_WORKERS:
					pHumanPlayer->vN = COMMENT_CHAIN_BUSY_WORKERS;
					break;
				default:
					pHumanPlayer->vFlag2 = FALSE;
					break;
				}
				if (pHumanPlayer->vFlag2 == TRUE)
				if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
				if (pHumanPlayer->vFlag2 == TRUE)
					return TRUE;
				goto m1;
			}
		}
	}
m1:;
	// Строительство юнитов и найм юнитов
	if (pHumanPlayer->vvi >= 0 && pHumanPlayer->vvi <= COMMENT_UNITS_OLD)
	if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi].vIdForComments == COMMENT_NO_UNIT)// и там нет юнита, то создаём его
	{
		pHumanPlayer->vCommentLast = COMMENT_MAIN_HUMAN;
		// Строим юниты по порядку, а если какого-то юнита нет, то строим его заного
		for (pHumanPlayer->vvj = 0; pHumanPlayer->vvj < 14; pHumanPlayer->vvj++)
		{
			if (pHumanPlayer->vSlayerBaze == FALSE)
			switch (pHumanPlayer->vvj)
			{
			case 0: pHumanPlayer->vComment = COMMENT_FIRST_DOM; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_DOM; break;
			case 1: pHumanPlayer->vComment = COMMENT_FIRST_TENT; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_TENT; break;
			case 2: pHumanPlayer->vComment = COMMENT_SECOND_TENT; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_TENT; break;
			case 3: pHumanPlayer->vComment = COMMENT_SECOND_DOM; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_DOM; break;
			case 4: pHumanPlayer->vComment = COMMENT_THIRD_TENT; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_TENT; break;
			case 5: pHumanPlayer->vComment = COMMENT_THIRD_DOM; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_DOM; break;
			case 6: pHumanPlayer->vComment = COMMENT_FOURTH_TENT; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_TENT; break;
			case 7: pHumanPlayer->vComment = COMMENT_FOURTH_DOM; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_DOM; break;
			case 8: pHumanPlayer->vComment = COMMENT_FIFTH_DOM; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_DOM; break;
			case 9: pHumanPlayer->vComment = COMMENT_SIXTH_DOM; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_DOM; break;
			case 10: pHumanPlayer->vComment = COMMENT_FIRST_KUZNYA; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_KUZNYA; break;
			case 11: pHumanPlayer->vComment = COMMENT_MAIN_WALL; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_WALL_BROWN; break;
			case 12: pHumanPlayer->vComment = COMMENT_TOWER_FOR_BLOCK_SHADE_1; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_TOWER_FOR_BLOCK_SHADE_1; break;
			case 13: pHumanPlayer->vComment = COMMENT_TOWER_FOR_BLOCK_SHADE_2; pHumanPlayer->vN = COMMENT_CHAIN_BUILD_TOWER_FOR_BLOCK_SHADE_2; break;
			}
			if (fIsMassCommentUnit(pHumanPlayer,pHumanPlayer->vCommentLast) == TRUE &&
				fIsMassCommentUnit(pHumanPlayer,pHumanPlayer->vComment) == FALSE)
			{
				pHumanPlayer->vCommentUnit = COMMENT_MAIN_HUMAN;
				if (fNCommentLast(pHumanPlayer) == FALSE)
				{
					pHumanPlayer->vError = 1;
					return FALSE;
				}
				if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
				break;
			}
			pHumanPlayer->vCommentLast = pHumanPlayer->vComment;
		}
		// Ставим флаги на деревья
		switch(pHumanPlayer->vComment)
		{
		case COMMENT_FIRST_DOM:
		case COMMENT_SECOND_DOM:
		case COMMENT_THIRD_DOM:
		case COMMENT_FOURTH_DOM:
		case COMMENT_FIFTH_DOM:
		case COMMENT_SIXTH_DOM:
			//pHumanPlayer->vComment = pHumanPlayer->vvi;
			//pHumanPlayer->vCommentUnit = COMMENT_MAIN_HUMAN;
			//pHumanPlayer->vN = COMMENT_CHAIN_BUILD_DOM;
			//pHumanPlayer->vMassCommentUnit[pHumanPlayer->vComment] = pHumanPlayer->vComment;
			//if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
			pHumanPlayer->vCommentUnit = pHumanPlayer->vvi;
			pHumanPlayer->vN = COMMENT_CHAIN_FLAG_DOM;
			if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
			break;
		}
		// Нанимаем рабочих в домиках
		switch(pHumanPlayer->vComment)
		{
		case COMMENT_FIRST_DOM:
		case COMMENT_SECOND_DOM:
		case COMMENT_THIRD_DOM:
		case COMMENT_FOURTH_DOM:
			pHumanPlayer->vCommentUnit = pHumanPlayer->vvi;
			pHumanPlayer->vN = COMMENT_CHAIN_7_WORKERS_DOM;
			if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
			break;
		case COMMENT_FIFTH_DOM:
		case COMMENT_SIXTH_DOM:
			pHumanPlayer->vCommentUnit = pHumanPlayer->vvi;
			pHumanPlayer->vN = COMMENT_CHAIN_5_WORKERS_DOM;
			if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
			break;
		}
		// Специальные действия
		switch(pHumanPlayer->vComment)
		{
		case COMMENT_MAIN_WALL:
			pHumanPlayer->vN = COMMENT_CHAIN_BACK_WALL;
			if (fChains(pHumanPlayer) == FALSE) pHumanPlayer->vError = 1;
			break;
		}
		return TRUE;
	}
	else
	{
		pHumanPlayer->vComment = pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi].vIdForComments;
		if (fNCommentLast(pHumanPlayer) == FALSE)
		{
			pHumanPlayer->vError = 1;
			return FALSE;
		}
	}
	pHumanPlayer->vComment = fFreeCommentUnit(pHumanPlayer);*/
	return TRUE;
}

bool fNCommentLast(HumanPlayer *pHumanPlayer)
{
	/*if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vComment >= MAX_COUNT_UNITS) return FALSE;
	pHumanPlayer->vMassCommentUnit[pHumanPlayer->vComment] = pHumanPlayer->vComment;
	if (pHumanPlayer->vNCommentLast < pHumanPlayer->vComment)
	{
		pHumanPlayer->vNCommentLast = pHumanPlayer->vComment;
	}*/
	return TRUE;
}

bool fIsMassCommentUnit(HumanPlayer *pHumanPlayer, unsigned short vComment)
{
	/*if (pHumanPlayer == NULL) return FALSE;
	if (vComment >= 0 && vComment <= COMMENT_UNITS_OLD)
	{
		if (pHumanPlayer->vMassCommentUnit[vComment] == vComment)
		{
			return TRUE;
		}
	}
	for (pHumanPlayer->vvz = 0; pHumanPlayer->vvz < MAX_COUNT_UNITS; pHumanPlayer->vvz++)
	{
		if (pHumanPlayer->vMassCommentUnit[pHumanPlayer->vvz] == vComment)
		{
			return TRUE;
		}
	}*/
	return FALSE;
}

bool fChains(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vQNumForChains >= pHumanPlayer->MAX_Q_NUM_FOR_MASS_CHAINS) return FALSE;
	pHumanPlayer->vFlagForMassResultChain = TRUE;
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < pHumanPlayer->vQNumForChains; pHumanPlayer->vvi++)
	{
		if (fAllChains(pHumanPlayer,pHumanPlayer->vMassNumForChains[pHumanPlayer->vvi]) == FALSE)
		{
			pHumanPlayer->vFlagForMassResultChain = FALSE;
			fDelAllChainsPlayer(pHumanPlayer);
			break;
		}
	}
	return pHumanPlayer->vFlagForMassResultChain;
}

bool fAllChains(HumanPlayer *pHumanPlayer, unsigned short vN)
{
	if (pHumanPlayer == NULL) return FALSE;
	pHumanPlayer->vFlagForResultChain = FALSE;
	switch(vN)
	{
	case 0:
		sprintf(vBuf,"%s\0","Строительство первого домика");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FIRST_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 1:
		sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у первого домика");
		if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_FIRST_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 2:
		sprintf(vBuf,"%s\0","Тренеруем 7 рабочих в первом домике");
		if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_WORKER,7,TRUE,COMMENT_FIRST_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 3:
		sprintf(vBuf,"%s\0","Строим первый тент");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FIRST_TENT,ID_UNIT_BUILD_TENT,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 4:
		sprintf(vBuf,"%s\0","Строим второй тент");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_SECOND_TENT,ID_UNIT_BUILD_TENT,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 5:
		sprintf(vBuf,"%s\0","Строим второй домик");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_SECOND_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 6:
		sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у второго домика");
		if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_SECOND_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 7:
		sprintf(vBuf,"%s\0","Тренеруем 7 рабочих во втором домике");
		if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_WORKER,7,TRUE,COMMENT_SECOND_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 8:
		sprintf(vBuf,"%s\0","Строим третий тент");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_THIRD_TENT,ID_UNIT_BUILD_TENT,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 9:
		sprintf(vBuf,"%s\0","Строим третий домик");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_THIRD_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 10:
		sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у третего домика");
		if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_THIRD_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 11:
		sprintf(vBuf,"%s\0","Тренеруем 7 рабочих в третьем домике");
		if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_WORKER,7,TRUE,COMMENT_THIRD_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 12:
		sprintf(vBuf,"%s\0","Строим четвёртый тент");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FOURTH_TENT,ID_UNIT_BUILD_TENT,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 13:
		sprintf(vBuf,"%s\0","Строим четвёртый дом");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FOURTH_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 14:
		sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у четвёртого дома");
		if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_FOURTH_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 15:
		sprintf(vBuf,"%s\0","Строим пятый дом");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FIFTH_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 16:
		sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у пятого дома");
		if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_FIFTH_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 17:
		sprintf(vBuf,"%s\0","Тренеруем 7 рабочих в четвёртом доме");
		if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_WORKER,7,TRUE,COMMENT_FOURTH_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 18:
		sprintf(vBuf,"%s\0","Строим шестой дом");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_SIXTH_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 19:
		sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у шестого дома");
		if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_SIXTH_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 20:
		sprintf(vBuf,"%s\0","Тренеруем 5 рабочих в пятом доме");
		if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_WORKER,5,FALSE,COMMENT_FIFTH_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 21:
		sprintf(vBuf,"%s\0","Строим первую кузню");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FIRST_KUZNYA,ID_UNIT_BUILD_KUZNYA,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 22:
		sprintf(vBuf,"%s\0","Строим кориченвый вал");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_MAIN_WALL,ID_UNIT_BUILD_WALL_BROWN,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 23:
		sprintf(vBuf,"%s\0","Отойти за стенку");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,205,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 24:
		sprintf(vBuf,"%s\0","Грейдим первый тент");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_GRADE_TENT,COMMENT_FIRST_TENT,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 25:
		sprintf(vBuf,"%s\0","Грейдим второй тент");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_GRADE_TENT,COMMENT_SECOND_TENT,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 26:
		sprintf(vBuf,"%s\0","Грейдим третий тент");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_GRADE_TENT,COMMENT_THIRD_TENT,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 27:
		sprintf(vBuf,"%s\0","Грейдим четвёртый тент");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_GRADE_TENT,COMMENT_FOURTH_TENT,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 28:
		sprintf(vBuf,"%s\0","Найм рабочих до фула");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,65,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 29:
		sprintf(vBuf,"%s\0","Комментирование рабочих в занатяых");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,66,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 30:
		sprintf(vBuf,"%s\0","Грейдим мейн вал в желтый");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_WALL_YELLOW,COMMENT_MAIN_WALL,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 31:
		sprintf(vBuf,"%s\0","Строим первую пушку для загародки от тени");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_TOWER_FOR_BLOCK_SHADE_1,ID_UNIT_BUILD_TOWER_WHITE,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 32:
		sprintf(vBuf,"%s\0","Строим вторую пушку для загародки от тени");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_TOWER_FOR_BLOCK_SHADE_2,ID_UNIT_BUILD_TOWER_WHITE,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 33:
		sprintf(vBuf,"%s\0","Грейдим мейн вал в фиолетовый");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_WALL_VIOLET,COMMENT_MAIN_WALL,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 34:
		sprintf(vBuf,"%s\0","Улучшаем хп валу первый раз в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_GEM1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 35:
		//sprintf(vBuf,"%s\0","Улучшаем добычу леса в первый раз в первой кузне");
		//if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_LES1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 36:
		sprintf(vBuf,"%s\0","Строим белые пушки и грейдим их в золотые");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,80,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 37:
		sprintf(vBuf,"%s\0","Грейдим пушки в золотые");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,81,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 38:
		sprintf(vBuf,"%s\0","Строим слаерку");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_TAVERN_SLAYER,ID_UNIT_BUILD_SLAYER_TAVERN,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 39:
		sprintf(vBuf,"%s\0","Нанимаем слаера");
		if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_SLAYER1,1,TRUE,COMMENT_TAVERN_SLAYER,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 40:
		sprintf(vBuf,"%s\0","Найти безопасную зону на базе");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,72,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 41:
		sprintf(vBuf,"%s\0","Блинкнуться в безопасную зону");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,73,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 42:
		sprintf(vBuf,"%s\0","Улучшаем добычу леса в первый раз в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_LES1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 43:
		sprintf(vBuf,"%s\0","Улучшаем хп валу второй раз в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_GEM2,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 44:
		sprintf(vBuf,"%s\0","Улучшаем хп валу третий раз в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_GEM3,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;			
	case 45:
		sprintf(vBuf,"%s\0","Улучшаем добычу леса во второй раз в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_LES2,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 46:
		sprintf(vBuf,"%s\0","Улучшаем добычу леса в третий раз в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_LES3,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 47:
		sprintf(vBuf,"%s\0","Улучшаем скорость рубки в первый раз в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_LES_SPEED1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 48:
		sprintf(vBuf,"%s\0","Улучшаем мана рег в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_MANA_REG,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 49:
		sprintf(vBuf,"%s\0","Улучшаем броню слаеру в первый раз в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_SLAYER_ARMOR1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 50:
		sprintf(vBuf,"%s\0","Улучшаем статы слаеру в первый раз в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_SLAYER_UPGRADE1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 51:
		sprintf(vBuf,"%s\0","Ждём голд");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,83,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 52:
		sprintf(vBuf,"%s\0","Строим храм");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_TEMPLE,ID_UNIT_BUILD_HRAM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 53:
		sprintf(vBuf,"%s\0","Строим 4 конуса");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,207,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 54:
		sprintf(vBuf,"%s\0","Запускаем цепочку имба №1");
		if (fNewChainAction(pHumanPlayer,FALSE,vN,CHAIN_ACTION_IMBA_1,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 55:
		sprintf(vBuf,"%s\0","Грейдим первый дом до лесопилки");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_LESOPILKA1,COMMENT_FIRST_DOM,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 56:
		sprintf(vBuf,"%s\0","Строим голд майн");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_BUSY_UNIT,ID_UNIT_BUILD_GOLD_MINE_WHITE,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 57:
		sprintf(vBuf,"%s\0","Улучшаем хп рабочим в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_HP_WORKERS,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 58:
		sprintf(vBuf,"%s\0","Грейдим мейн вал в синий");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_WALL_BLUE,COMMENT_MAIN_WALL,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 59:
		sprintf(vBuf,"%s\0","Меняем эру на 1");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,101,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 60:
		sprintf(vBuf,"%s\0","Строим защиту от вампа слаеру");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_HOUSE_FOR_BLOCK_VAMPIRE,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) pHumanPlayer->vFlagForResultChain = TRUE;
		break;
	case 61:
		sprintf(vBuf,"%s\0","Что в эре 1?");
		break;
	default:
		pHumanPlayer->vFlagForResultChain = FALSE;
		break;
	}
	return pHumanPlayer->vFlagForResultChain;
}

//bool fChains(HumanPlayer *pHumanPlayer)
//{
	/*if (pHumanPlayer == NULL) return FALSE;
	//pHumanPlayer->vError = 0;
	pHumanPlayer->vFlag = 0;
	switch(pHumanPlayer->vN)
	{
	case 0:
		pHumanPlayer->vFlag = 0;
		break;
	case 1:
		sprintf(vBuf,"%s\0","Домик для рубки леса");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,pHumanPlayer->vN,pHumanPlayer->vComment,ID_UNIT_BUILD_DOM,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 2:
		sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у домика для рубки леса");
		if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,pHumanPlayer->vN,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 3:
		sprintf(vBuf,"%s\0","Тренеруем 7 рабочих в домике для рубки леса");
		if (fNewChainActionTrain(pHumanPlayer,FALSE,pHumanPlayer->vN,ID_UNIT_WORKER,7,TRUE,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 4:
		sprintf(vBuf,"%s\0","Строим тент");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,pHumanPlayer->vN,pHumanPlayer->vComment,ID_UNIT_BUILD_TENT,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 5:
		sprintf(vBuf,"%s\0","Тренеруем 5 рабочих в домике для рубки леса");
		if (fNewChainActionTrain(pHumanPlayer,FALSE,pHumanPlayer->vN,ID_UNIT_WORKER,5,FALSE,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 6:
		sprintf(vBuf,"%s\0","Строим кузню");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,pHumanPlayer->vN,pHumanPlayer->vComment,ID_UNIT_BUILD_KUZNYA,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 7:
		sprintf(vBuf,"%s\0","Строим кориченвый вал");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,pHumanPlayer->vN,pHumanPlayer->vComment,ID_UNIT_BUILD_WALL_BROWN,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 8:
		sprintf(vBuf,"%s\0","Отойти за стенку");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,pHumanPlayer->vN,205,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 9:
		sprintf(vBuf,"%s\0","Грейдим тент");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,pHumanPlayer->vN,ID_UNIT_BUILD_GRADE_TENT,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 10:
		sprintf(vBuf,"%s\0","Найм рабочих до фула");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,pHumanPlayer->vN,65,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 11:
		sprintf(vBuf,"%s\0","Комментирование рабочих в занатяых");
		if (fNewChainActionUniversal(pHumanPlayer,FALSE,pHumanPlayer->vN,66,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 12:
		sprintf(vBuf,"%s\0","Грейдим мейн вал в желтый");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,pHumanPlayer->vN,ID_UNIT_BUILD_WALL_YELLOW,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 13:
		sprintf(vBuf,"%s\0","Строим первую пушку для загародки от тени");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,pHumanPlayer->vN,pHumanPlayer->vComment,ID_UNIT_BUILD_TOWER_WHITE,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 14:
		sprintf(vBuf,"%s\0","Строим вторую пушку для загародки от тени");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,pHumanPlayer->vN,pHumanPlayer->vComment,ID_UNIT_BUILD_TOWER_WHITE,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 15:
		sprintf(vBuf,"%s\0","Грейдим мейн вал в фиолетовый");
		if (fNewChainActionUpgrade(pHumanPlayer,FALSE,pHumanPlayer->vN,ID_UNIT_BUILD_WALL_VIOLET,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;
	case 16:
		sprintf(vBuf,"%s\0","Улучшаем хп валу первый раз");
		if (fNewChainActionResearch(pHumanPlayer,FALSE,pHumanPlayer->vN,N_RESEARCH_GEM1,pHumanPlayer->vCommentUnit,vBuf) == TRUE) pHumanPlayer->vFlag = 1;
		break;*/
	/*		case 36:
			sprintf(vBuf,"%s\0","Строим белые пушки и грейдим их в золотые");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,80,vBuf) == TRUE) vFlag = 1;
			break;
		case 37:
			sprintf(vBuf,"%s\0","Грейдим пушки в золотые");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,81,vBuf) == TRUE) vFlag = 1;
			break;
		case 38:
			sprintf(vBuf,"%s\0","Строим слаерку");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_TAVERN_SLAYER,ID_UNIT_BUILD_SLAYER_TAVERN,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 39:
			sprintf(vBuf,"%s\0","Нанимаем слаера");
			if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_SLAYER1,1,TRUE,COMMENT_TAVERN_SLAYER,vBuf) == TRUE) vFlag = 1;
			break;
		case 40:
			sprintf(vBuf,"%s\0","Найти безопасную зону на базе");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,72,vBuf) == TRUE) vFlag = 1;
			break;
			*/
	/*}
	if (pHumanPlayer->vFlag == 1)
	{
		pHumanPlayer->vNLast = pHumanPlayer->vN;
		return TRUE;
	}*/
	//return FALSE;
//}

bool fChainsEra1_New(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	// План есть?
}

// Найти свободный коммент в юнитах
unsigned short fFreeCommentUnit(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < pHumanPlayer->vParamPlayer.MAX_UNIT; pHumanPlayer->vvi++)
	{
		if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi].vIdForComments != pHumanPlayer->vvi)
		{
			return pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi].vIdForComments;
		}
	}
	return pHumanPlayer->vParamPlayer.MAX_UNIT;
}

bool fChainsEra0(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	Integer vN;
	Integer vCount;
	Integer vError;
	Integer vFlag;
	Integer vFlag2;
	bool vSlayerBaze;
	vSlayerBaze = pHumanPlayer->vBase.vSlayerBaze;
	vCount = 0;
	vN = 0;
	vError = 0;
	vFlag2 = 0;
	while (vCount < 200)
	{
		vFlag = 0;
		switch(vN)
		{
		case 0:
			sprintf(vBuf,"%s\0","Строительство первого домика");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FIRST_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 1:
			sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у первого домика");
			if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_FIRST_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 2:
			sprintf(vBuf,"%s\0","Тренеруем 7 рабочих в первом домике");
			if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_WORKER,7,TRUE,COMMENT_FIRST_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 3:
			sprintf(vBuf,"%s\0","Строим первый тент");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FIRST_TENT,ID_UNIT_BUILD_TENT,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 4:
			sprintf(vBuf,"%s\0","Строим второй тент");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_SECOND_TENT,ID_UNIT_BUILD_TENT,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 5:
			sprintf(vBuf,"%s\0","Строим второй домик");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_SECOND_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 6:
			sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у второго домика");
			if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_SECOND_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 7:
			sprintf(vBuf,"%s\0","Тренеруем 7 рабочих во втором домике");
			if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_WORKER,7,TRUE,COMMENT_SECOND_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 8:
			sprintf(vBuf,"%s\0","Строим третий тент");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_THIRD_TENT,ID_UNIT_BUILD_TENT,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 9:
			sprintf(vBuf,"%s\0","Строим третий домик");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_THIRD_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 10:
			sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у третего домика");
			if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_THIRD_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 11:
			sprintf(vBuf,"%s\0","Тренеруем 7 рабочих в третьем домике");
			if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_WORKER,7,TRUE,COMMENT_THIRD_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 12:
			sprintf(vBuf,"%s\0","Строим четвёртый тент");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FOURTH_TENT,ID_UNIT_BUILD_TENT,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 13:
			sprintf(vBuf,"%s\0","Строим четвёртый дом");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FOURTH_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 14:
			sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у четвёртого дома");
			if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_FOURTH_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 15:
			sprintf(vBuf,"%s\0","Строим пятый дом");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FIFTH_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 16:
			sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у пятого дома");
			if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_FIFTH_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 17:
			sprintf(vBuf,"%s\0","Тренеруем 7 рабочих в четвёртом доме");
			if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_WORKER,7,TRUE,COMMENT_FOURTH_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 18:
			sprintf(vBuf,"%s\0","Строим шестой дом");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_SIXTH_DOM,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 19:
			sprintf(vBuf,"%s\0","Ставим флаг на ближайшее дерево у шестого дома");
			if (fNewChainActionSetFlagToNearestTree(pHumanPlayer,FALSE,vN,COMMENT_SIXTH_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 20:
			sprintf(vBuf,"%s\0","Тренеруем 5 рабочих в пятом доме");
			if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_WORKER,5,FALSE,COMMENT_FIFTH_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 21:
			sprintf(vBuf,"%s\0","Строим первую кузню");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_FIRST_KUZNYA,ID_UNIT_BUILD_KUZNYA,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 22:
			sprintf(vBuf,"%s\0","Строим кориченвый вал");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_MAIN_WALL,ID_UNIT_BUILD_WALL_BROWN,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 23:
			sprintf(vBuf,"%s\0","Отойти за стенку");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,205,vBuf) == TRUE) vFlag = 1;
			break;
		case 24:
			sprintf(vBuf,"%s\0","Грейдим первый тент");
			if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_GRADE_TENT,COMMENT_FIRST_TENT,vBuf) == TRUE) vFlag = 1;
			break;
		case 25:
			sprintf(vBuf,"%s\0","Грейдим второй тент");
			if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_GRADE_TENT,COMMENT_SECOND_TENT,vBuf) == TRUE) vFlag = 1;
			break;
		case 26:
			sprintf(vBuf,"%s\0","Грейдим третий тент");
			if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_GRADE_TENT,COMMENT_THIRD_TENT,vBuf) == TRUE) vFlag = 1;
			break;
		case 27:
			sprintf(vBuf,"%s\0","Грейдим четвёртый тент");
			if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_GRADE_TENT,COMMENT_FOURTH_TENT,vBuf) == TRUE) vFlag = 1;
			break;
		case 28:
			sprintf(vBuf,"%s\0","Найм рабочих до фула");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,65,vBuf) == TRUE) vFlag = 1;
			break;
		case 29:
			sprintf(vBuf,"%s\0","Комментирование рабочих в занатяых");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,66,vBuf) == TRUE) vFlag = 1;
			break;
		case 30:
			sprintf(vBuf,"%s\0","Грейдим мейн вал в желтый");
			if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_WALL_YELLOW,COMMENT_MAIN_WALL,vBuf) == TRUE) vFlag = 1;
			break;
		case 31:
			sprintf(vBuf,"%s\0","Строим первую пушку для загародки от тени");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_TOWER_FOR_BLOCK_SHADE_1,ID_UNIT_BUILD_TOWER_WHITE,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 32:
			sprintf(vBuf,"%s\0","Строим вторую пушку для загародки от тени");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_TOWER_FOR_BLOCK_SHADE_2,ID_UNIT_BUILD_TOWER_WHITE,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 33:
			sprintf(vBuf,"%s\0","Грейдим мейн вал в фиолетовый");
			if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_WALL_VIOLET,COMMENT_MAIN_WALL,vBuf) == TRUE) vFlag = 1;
			break;
		case 34:
			sprintf(vBuf,"%s\0","Улучшаем хп валу первый раз в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_GEM1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;
		case 35:
			//sprintf(vBuf,"%s\0","Улучшаем добычу леса в первый раз в первой кузне");
			//if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_LES1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			vFlag = 1;
			break;
		case 36:
			sprintf(vBuf,"%s\0","Строим белые пушки и грейдим их в золотые");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,80,vBuf) == TRUE) vFlag = 1;
			break;
		case 37:
			sprintf(vBuf,"%s\0","Грейдим пушки в золотые");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,81,vBuf) == TRUE) vFlag = 1;
			break;
		case 38:
			sprintf(vBuf,"%s\0","Строим слаерку");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_TAVERN_SLAYER,ID_UNIT_BUILD_SLAYER_TAVERN,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 39:
			sprintf(vBuf,"%s\0","Нанимаем слаера");
			if (fNewChainActionTrain(pHumanPlayer,FALSE,vN,ID_UNIT_SLAYER1,1,TRUE,COMMENT_TAVERN_SLAYER,vBuf) == TRUE) vFlag = 1;
			break;
		case 40:
			sprintf(vBuf,"%s\0","Найти безопасную зону на базе");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,72,vBuf) == TRUE) vFlag = 1;
			break;
		case 41:
			sprintf(vBuf,"%s\0","Блинкнуться в безопасную зону");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,73,vBuf) == TRUE) vFlag = 1;
			break;
		case 42:
			sprintf(vBuf,"%s\0","Улучшаем добычу леса в первый раз в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_LES1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;
		case 43:
			sprintf(vBuf,"%s\0","Улучшаем хп валу второй раз в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_GEM2,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;
		case 44:
			sprintf(vBuf,"%s\0","Улучшаем хп валу третий раз в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_GEM3,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;			
		case 45:
			sprintf(vBuf,"%s\0","Улучшаем добычу леса во второй раз в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_LES2,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;
		case 46:
			sprintf(vBuf,"%s\0","Улучшаем добычу леса в третий раз в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_LES3,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;
		case 47:
			sprintf(vBuf,"%s\0","Улучшаем скорость рубки в первый раз в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_LES_SPEED1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;
		case 48:
			sprintf(vBuf,"%s\0","Улучшаем мана рег в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_MANA_REG,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;
		case 49:
			sprintf(vBuf,"%s\0","Улучшаем броню слаеру в первый раз в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_SLAYER_ARMOR1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;
		case 50:
			sprintf(vBuf,"%s\0","Улучшаем статы слаеру в первый раз в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_SLAYER_UPGRADE1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;
		case 51:
			sprintf(vBuf,"%s\0","Ждём голд");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,83,vBuf) == TRUE) vFlag = 1;
			break;
		case 52:
			sprintf(vBuf,"%s\0","Строим храм");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_TEMPLE,ID_UNIT_BUILD_HRAM,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 53:
			sprintf(vBuf,"%s\0","Строим 4 конуса");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,207,vBuf) == TRUE) vFlag = 1;
			break;
		case 54:
			sprintf(vBuf,"%s\0","Запускаем цепочку имба №1");
			if (fNewChainAction(pHumanPlayer,FALSE,vN,CHAIN_ACTION_IMBA_1,vBuf) == TRUE) vFlag = 1;
			break;
		case 55:
			sprintf(vBuf,"%s\0","Грейдим первый дом до лесопилки");
			if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_LESOPILKA1,COMMENT_FIRST_DOM,vBuf) == TRUE) vFlag = 1;
			break;
		case 56:
			sprintf(vBuf,"%s\0","Строим голд майн");
			if (fNewChainActionBuild(pHumanPlayer,FALSE,vN,COMMENT_BUSY_UNIT,ID_UNIT_BUILD_GOLD_MINE_WHITE,COMMENT_MAIN_HUMAN,vBuf) == TRUE) vFlag = 1;
			break;
		case 57:
			sprintf(vBuf,"%s\0","Улучшаем хп рабочим в первой кузне");
			if (fNewChainActionResearch(pHumanPlayer,FALSE,vN,N_RESEARCH_HP_WORKERS,COMMENT_FIRST_KUZNYA,vBuf) == TRUE) vFlag = 1;
			break;
		case 58:
			sprintf(vBuf,"%s\0","Грейдим мейн вал в синий");
			if (fNewChainActionUpgrade(pHumanPlayer,FALSE,vN,ID_UNIT_BUILD_WALL_BLUE,COMMENT_MAIN_WALL,vBuf) == TRUE) vFlag = 1;
			break;
		case 59:
			sprintf(vBuf,"%s\0","Меняем эру на 1");
			if (fNewChainActionUniversal(pHumanPlayer,FALSE,vN,101,vBuf) == TRUE) vFlag = 1;
			break;
		}
		if (vFlag == 1)
		{
			if (vSlayerBaze == FALSE)
			{
				vN++;
			}
			else
			{
				switch(vN)
				{
				case 17:
					vN = 24;
					break;
				case 20:
					if (vFlag2 == 0)
					{
						vN = 38;
						vFlag2 = 1;
						break;
					}
					if (vFlag2 == 1)
					{
						vN = 20;
						vFlag2 = 2;
						break;
					}
					if (vFlag2 == 2)
					{
						vN = 26;
						vFlag2 = 0;
						break;
					}
					break;
				case 25:
					vN = 20;
					break;
				case 39:
					vN = 18;
					break;
				case 29:
					vN = 21;
					break;
				case 23:
					vN = 31;
					break;
				case 32:
					vN = 30;
					break;
				/*case 41:
					if (vFlag2 == 0)
					{
						vN = 42;
						vFlag2 = 1;
						break;
					}
					if (vFlag2 == 1)
					{
						vN = 51;
						vFlag2 = 0;
						vSlayerBaze = FALSE;
						break;
					}
					break;*/
				//case 42:
				//	vN = 45;
				//	break;
				//case 50:
				//	vN = 34;
				//	break;
				//case 34:
				//	vN = 43;
				//	break;
				//case 44:
				//	vN = 30;
				//	break;
				case 30:
					vN = 33;
					break;
				case 34:
					vN = 36;
					break;
				case 37:
					vN = 40;
					vSlayerBaze = FALSE;
					break;
				default:
					vN++;
					break;
				}
			}
		}
		else
		{
			vError = 1;
		}
		if (vN >= 60)
		{
			break;
		}
		vCount++;
	}
	//pHumanPlayer->vNFree = vN;
	if (vN >= 60 && pHumanPlayer->vBase.vSlayerBaze == TRUE)
	{
		pHumanPlayer->vBase.vNChainForHouseForBlockVampire = fFindFreeNChain(pHumanPlayer);
		if (pHumanPlayer->vBase.vNChainForHouseForBlockVampire <= 0) goto m23;
		sprintf(vBuf,"%s\0","Строим защиту от вампа слаеру");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,pHumanPlayer->vBase.vNChainForHouseForBlockVampire,COMMENT_HOUSE_FOR_BLOCK_VAMPIRE,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
		fShiftChainLastToN(pHumanPlayer,39);
m23:;
	}
	if (vN >= 60 && pHumanPlayer->vBase.vSlayerBaze == FALSE)
	{
		pHumanPlayer->vBase.vNChainForHouseForBlockVampire = fFindFreeNChain(pHumanPlayer);
		if (pHumanPlayer->vBase.vNChainForHouseForBlockVampire <= 0) goto m24;
		sprintf(vBuf,"%s\0","Строим защиту от вампа");
		if (fNewChainActionBuild(pHumanPlayer,FALSE,pHumanPlayer->vBase.vNChainForHouseForBlockVampire,COMMENT_HOUSE_FOR_BLOCK_VAMPIRE,ID_UNIT_BUILD_DOM,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
		fShiftChainLastToN(pHumanPlayer,33);
m24:;
	}
	return TRUE;
}

// Маршрутизация действий
void fMapRoutingActions(HumanPlayer *pHumanPlayer)
{
	/*if (pHumanPlayer == NULL) return;
	Integer vError;
	Integer vAction;
	Integer vCount;
	Integer vFlag;
	vError = 0;
	if (pHumanPlayer->vCurrentEra == 0)
	{
		if (pHumanPlayer->vParamPlayer.vStage == 203 &&
			pHumanPlayer->vBase.vSlayerBaze == TRUE)
		{
			pHumanPlayer->vBase.vSlayerBaze = FALSE;
		}
		if (pHumanPlayer->vParamPlayer.vStage == 65)
		{
			if (!(pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_TENT].vIdForComments == COMMENT_FIRST_TENT &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_TENT].pDataUnit->vId == ID_UNIT_BUILD_GRADE_TENT ||
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_TENT].pDataUnit->vTimeEndTrain > pHumanPlayer->vParamPlayer.vTimerGetElapsed) &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_TENT].vIdForComments == COMMENT_SECOND_TENT &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_TENT].pDataUnit->vId == ID_UNIT_BUILD_GRADE_TENT ||
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_TENT].pDataUnit->vTimeEndTrain > pHumanPlayer->vParamPlayer.vTimerGetElapsed) &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_TENT].vIdForComments == COMMENT_THIRD_TENT &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_TENT].pDataUnit->vId == ID_UNIT_BUILD_GRADE_TENT ||
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_TENT].pDataUnit->vTimeEndTrain > pHumanPlayer->vParamPlayer.vTimerGetElapsed) &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].vIdForComments == COMMENT_FOURTH_TENT &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].pDataUnit->vId == ID_UNIT_BUILD_GRADE_TENT ||
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].pDataUnit->vTimeEndTrain > pHumanPlayer->vParamPlayer.vTimerGetElapsed)))
			{
				if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].vIdForComments == COMMENT_FOURTH_TENT &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].pDataUnit->vTimeEndTrain > pHumanPlayer->vParamPlayer.vTimerGetElapsed)
				{
					vBundle = NULL;
					if (fAddActionInStackActions(pHumanPlayer,60,FALSE,11) == TRUE)
					if (fAddActionInStackActions(pHumanPlayer,62,FALSE,11) == TRUE)
					if (fAddActionInStackActions(pHumanPlayer,63,FALSE,11) == TRUE)
					if (fAddActionInStackActions(pHumanPlayer,64,FALSE,11) == TRUE)
					{
						if (fAddActionInStackActions(pHumanPlayer,0,TRUE,11) == TRUE)
						{
							goto m2;
						}
					}
				}
			}
		}
		if (pHumanPlayer->vParamPlayer.vStage == 56 &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA)
		{
			if (vFreeCurrentActionInStackActions_2(pHumanPlayer) == FALSE)
			{
				vError = 2;
			}
			vBundle = NULL;
			if (fAddActionInStackActions(pHumanPlayer,58,FALSE,10) == TRUE)
			{
				if (fAddActionInStackActions(pHumanPlayer,0,TRUE,10) == TRUE)
				{
					goto m2;
				}
			}
		}
		if (pHumanPlayer->vParamPlayer.vStage == 94)
		{
			vAction = 0;
			if (fAllWood(pHumanPlayer) >= 45000)
			{
				pHumanPlayer->vFlagImba = FALSE;
			}
			if (pHumanPlayer->vFlagImba == TRUE &&
				(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeImba > 25) &&
				(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeAttackWall > 10))
			{
				// Отменяем строительство вала и двух пушек красных
				fAddDataUnitInRange(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit);
				fCancel_1(pHumanPlayer,0);
				pHumanPlayer->vTimeImba = FALSE;
				if (fAllWood(pHumanPlayer) >= 20000 &&
					fGetAllWood(pHumanPlayer) == TRUE)
				{
					vAction = 95;
				}
				else
				{
					vAction = 83;
				}
			}
			if (pHumanPlayer->vFlagImba == FALSE)
			{
				vAction = 95;
			}
			if (vAction != 0)
			{
				if (vFreeCurrentActionInStackActions_2(pHumanPlayer) == FALSE)
				{
					vError = 2;
				}
				vBundle = NULL;
				if (fAddActionInStackActions(pHumanPlayer,vAction,FALSE,4) == TRUE)
				{
					if (fAddActionInStackActions(pHumanPlayer,0,TRUE,4) == TRUE)
					{
						goto m2;
					}
				}
			}
		}
		if (pHumanPlayer->vParamPlayer.vStage == 83 &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TEMPLE].vIdForComments == COMMENT_TEMPLE)
		{
			if (vFreeCurrentActionInStackActions_2(pHumanPlayer) == FALSE)
			{
				vError = 2;
			}
			pHumanPlayer->vFlagImba = TRUE;
			vBundle = NULL;
			if (fAddActionInStackActions(pHumanPlayer,88,FALSE,3) == TRUE)
			{
				if (fAddActionInStackActions(pHumanPlayer,0,TRUE,3) == TRUE)
				{
					goto m2;
				}
			}
		}
		// 70 постройка слаерки
		// 307 найм слаера
		if (((pHumanPlayer->vParamPlayer.vStage == 67 &&
			pHumanPlayer->vBase.vSlayerBaze == TRUE) ||
			(pHumanPlayer->vParamPlayer.vStage == 82 &&
			pHumanPlayer->vBase.vSlayerBaze == FALSE) ||
			pHumanPlayer->vForerunnerStage == 307) &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].vIdForComments != COMMENT_TAVERN_SLAYER)
		{
			if (vFreeCurrentActionInStackActions_2(pHumanPlayer) == FALSE)
			{
				vError = 2;
			}
			vBundle = NULL;
			if (fAddActionInStackActions(pHumanPlayer,303,FALSE,1) == TRUE)
			if (fAddActionInStackActions(pHumanPlayer,304,FALSE,1) == TRUE)
			if (fAddActionInStackActions(pHumanPlayer,305,FALSE,1) == TRUE)
			if (fAddActionInStackActions(pHumanPlayer,306,FALSE,1) == TRUE)
			{
				if (fAddActionInStackActions(pHumanPlayer,0,TRUE,1) == TRUE)
				{
					goto m2;
				}
			}
		}
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].vIdForComments == COMMENT_TAVERN_SLAYER &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->Postroeno == TRUE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].vIdForComments != COMMENT_SLAYER &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->vIdTrain != ID_UNIT_SLAYER1 &&
			fIsEnoughResourses(pHumanPlayer->vParamPlayer.vPlayer,ID_UNIT_SLAYER1) == TRUE)
		{
			if (vFreeCurrentActionInStackActions_2(pHumanPlayer) == FALSE)
			{
				vError = 2;
			}
			vBundle = NULL;
			if (fAddActionInStackActions(pHumanPlayer,307,FALSE,2) == TRUE)
			{
				if (fAddActionInStackActions(pHumanPlayer,0,TRUE,2) == TRUE)
				{
					goto m2;
				}
			}
		}
	}
m2:
	if (vFreeCurrentActionInStackActions(pHumanPlayer) == FALSE)
	{
		vError = 2;
	}
	if (pHumanPlayer->vCurrentAction)
	{
		return;
	}
	if (pHumanPlayer->vCurrentEra == 0)
	{
		vAction = 0;
		vCount = 0;
		vFlag = 0;
		while(vCount < 200)
		{
m3:
			if (pHumanPlayer->vBase.vSlayerBaze == FALSE || vFlag == 2)
			{
				switch(vAction)
				{
				case 32:
					vAction = 39;
					goto m3;
				case 38:
					vAction = 201;
					goto m3;
				case 53:
					vAction = 54;
					goto m3;
				case 67:
					vAction = 68;
					goto m3;
				case 70:
					vAction = 80;
					goto m3;
				case 79:
					vAction = 83;
					goto m3;
				case 82:
					vAction = 83;
					goto m3;
				case 94:
					vAction = 95;
					goto m3;
				case 203:
					vAction = 74;
					goto m3;
				default:
					vAction++;
					break;
				}
			}
			else
			{
				switch(vAction)
				{
				case 32:
					vAction = 39;
					goto m3;
				case 38:
					vAction = 54;
					goto m3;
				case 53:
					vAction = 60;
					goto m3;
				case 67:
					if (vFlag == 0)
					{
						vAction = 54;
						vFlag = 1;
						goto m3;
					}
					if (vFlag == 1)
					{
						vAction = 58;
						vFlag = 2;
						goto m3;
					}
					if (vFlag == 2)
					{
						vAction = 68;
						vFlag = 0;
						goto m3;
					}
					goto m3;
				case 70:
					vAction = 38;
					goto m3;
				case 79:
					vAction = 80;
					goto m3;
				case 82:
					vAction = 201;
					goto m3;
				case 203:
					vAction = 74;
					vFlag = 2;
					goto m3;
				default:
					vAction++;
					break;
				}
			}
			if (vAction == 101 + 1)
			{
				break;
			}
			if (fAddActionInStackActions(pHumanPlayer,vAction-1,FALSE,0) == FALSE)
			{
				vError = 1;
			}
			vCount++;
		}
		pHumanPlayer->vNextEra = 1;
	}
	if (pHumanPlayer->vCurrentEra == 1)
	{
	}*/
}

bool fActionsHuman_Era0(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	// Если храм и лесопилка есть, то проверяем 20000 дерева и запрещаем ремонитровать вал
	if (pHumanPlayer->vBase.vTempleAndLumberHouse == TRUE)
	{
		if (fCheckRes(pHumanPlayer,0,20000) == FALSE)
		{
			pHumanPlayer->vBlockRepair = FALSE;
		}
		else
		{
			pHumanPlayer->vBlockRepair = TRUE;
		}
	}
	//
	/*if (((pDataHumans->vBaseHelp1 &&
		pDataHumans->vBaseHelp1 == &pHumanPlayer->vBase) ||
		(pDataHumans->vBaseHelp2 &&
		pDataHumans->vBaseHelp2 == &pHumanPlayer->vBase)) &&
		pHumanPlayer->vBase.vQFirstTower < 13 &&
		pHumanPlayer->vBase.fQPosRepair() >= 3 &&
		//pHumanPlayer->vActionStackForUnitsTower.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_WHITE) < 13 &&
		(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL))
	{
		if (GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE) >
			(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.9))
		{
			pHumanPlayer->vBlockRepair = TRUE;
		}
		else
		{
			pHumanPlayer->vBlockRepair = FALSE;
		}
	}*/
	/*if (pHumanPlayer->vFlagBuildHeal == TRUE &&
		pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_MANA_REG] == TRUE)
	{
		pHumanPlayer->vBlockRepair = TRUE;
	}*/
	// Отмена блока ремонта вала
	if (pHumanPlayer->vBlockRepair == TRUE)
	{
		if (pHumanPlayer->vFlagBuildHeal == TRUE &&
			((pHumanPlayer->vParamPlayer.vUnit[COMMENT_HEAL_1].vIdForComments == COMMENT_HEAL_1 &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_HEAL_2].vIdForComments == COMMENT_HEAL_2) ||
			((pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeBuildHeal > 80) &&
			pHumanPlayer->vTimeBuildHeal != 0)))
		{
			pHumanPlayer->vFlagBuildHeal = FALSE;
			pHumanPlayer->vBlockRepair = FALSE;
		}
		/*if (pHumanPlayer->vFlagBuildHeal == FALSE &&
			pHumanPlayer->vBase.vTempleAndLumberHouse == FALSE &&
			((pDataHumans->vBaseHelp1 &&
			pDataHumans->vBaseHelp1 == &pHumanPlayer->vBase) ||
			(pDataHumans->vBaseHelp2 &&
			pDataHumans->vBaseHelp2 == &pHumanPlayer->vBase)) &&
			pHumanPlayer->vBase.vQFirstTower >= 12 &&
			(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL))
		{
			pHumanPlayer->vBlockRepair = FALSE;
		}*/
		if (pHumanPlayer->vOneGoldImba == TRUE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TEMPLE].vIdForComments == COMMENT_TEMPLE)
		{
			pHumanPlayer->vOneGoldImba = FALSE;
			pHumanPlayer->vBlockRepair = FALSE;
		}
	}
	/*if (pHumanPlayer->vBlockRepair == TRUE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN)
	{
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelping = FALSE;
	}*/
	//if (pHumanPlayer->vFlagBuildHeal == TRUE) goto m15;
	// Строим пушку для убийства гривы и шамана
	if (pHumanPlayer->vTowerHouse == FALSE &&
		pHumanPlayer->vCurrentChain &&
		pHumanPlayer->vCurrentChain->vN > 41 &&
		pHumanPlayer->vTimeAttackWorker != 0 &&
		(pHumanPlayer->vBase.vShaman == TRUE ||
		(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeAttackWorker < 10)))
	{
		sprintf(vBuf,"%s\0","Апгрейживаем пушку");
		if (fNewChainActionUniversal(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),210,vBuf) == TRUE);
		sprintf(vBuf,"%s\0","Выбираем место для пушки");
		if (fNewChainActionUniversal(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),209,vBuf) == TRUE);
		pHumanPlayer->vTowerHouse = TRUE;
		return FALSE;
	}
	// Апгрейд брони слаерам
	if (pHumanPlayer->vFlagBuildHeal == FALSE &&
		pHumanPlayer->vTimeAttackWorker == 0)// Примочка
	if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_SLAYER_ARMOR3] == FALSE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].vIdForComments == COMMENT_TAVERN_SLAYER &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].vIdForComments == COMMENT_SLAYER &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE &&
		pHumanPlayer->vCurrentChain &&
		pHumanPlayer->vCurrentChain->vN > 41)//Больше 41 цепочки, качаем армор слаерам
	{
		if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_SLAYER_ARMOR1] == FALSE)// &&
			//pHumanPlayer->vArmorSlayer1 == FALSE)
		{
			if (pHumanPlayer->vMassChains[49] == FALSE && // 49 цепочка закончено нет
				pHumanPlayer->vCurrentChain &&//Текущая цепочка есть
				pHumanPlayer->vCurrentChain->vN != 49)//Текущая цепочка не 49
			{
				//pHumanPlayer->vArmorSlayer1 = TRUE;
				sprintf(vBuf,"%s\0","Улучшаем броню 1 слаерам");
				if (fNewChainActionResearch(pHumanPlayer,TRUE,49,N_RESEARCH_SLAYER_ARMOR1,COMMENT_FIRST_KUZNYA,vBuf) == TRUE);
			}
		}
		else if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_SLAYER_ARMOR2] == FALSE &&
				 pHumanPlayer->vMassChains[1] == FALSE)// &&
			//pHumanPlayer->vArmorSlayer2 == FALSE)
		{
			//pHumanPlayer->vArmorSlayer2 = TRUE;
			sprintf(vBuf,"%s\0","Улучшаем броню 2 слаерам");
			if (fNewChainActionResearch(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),N_RESEARCH_SLAYER_ARMOR2,COMMENT_FIRST_KUZNYA,vBuf) == TRUE);
		}
		else if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_SLAYER_ARMOR3] == FALSE &&
				 pHumanPlayer->vMassChains[1] == FALSE)// &&
			//pHumanPlayer->vArmorSlayer3 == FALSE)
		{
			//pHumanPlayer->vArmorSlayer3 = TRUE;
			sprintf(vBuf,"%s\0","Улучшаем броню 3 слаерам");
			if (fNewChainActionResearch(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),N_RESEARCH_SLAYER_ARMOR3,COMMENT_FIRST_KUZNYA,vBuf) == TRUE);
		}
	}
	// Отмена строительства
	if (pHumanPlayer->vFlagGoldTower == TRUE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&//мейн хуман есть
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vFlagBuild == TRUE)
	{
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vFlagBuild = FALSE;
	}
	if (pHumanPlayer->vBase.vSlayerBaze == FALSE &&//не слаерка
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&//мейн вал есть
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&//мейн хуман есть
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vFlagBuild == TRUE &&//Юнит строит
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE) < 
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.5))// У вала менее 50% хп
		)
	{
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vFlagBuild = FALSE;
	}
	// Строительство пушек, если союзники ченят вал
	if (pHumanPlayer->vFlagGoldTower == FALSE &&
		pHumanPlayer->vBase.vSlayerBaze == FALSE &&//не слаерка
		pHumanPlayer->vBase.vQFirstTower < 12 &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&//мейн вал есть
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&//мейн хуман есть
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vFlagBuild == FALSE &&//Юнит не строит
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Atakovan == TRUE &&
		(fQPosRepairMainHuman(&pHumanPlayer->vBase) >= (unsigned short)((double)5 / (double)MAX_HUMAN_PLAYERS * (double)vCountHumans))//ченят 5 или более
		&&
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE) > 
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.6))// У вала более 60% хп
		)
	{
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vFlagBuild = TRUE;
		sprintf(vBuf,"%s\0","Грейдим пушки пока вампы ломают вал");
		if (fNewChainActionUniversal(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),81,vBuf) == TRUE);
		sprintf(vBuf,"%s\0","Строим пушки пока вампы ломают вал");
		if (fNewChainActionUniversal(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),80,vBuf) == TRUE);
		//pHumanPlayer->vBlockRepair = TRUE;
		fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
		return TRUE;
	}
	// Строительство хилок
	if (pHumanPlayer->vBase.vSlayerBaze == FALSE &&//не слаерка
		pHumanPlayer->vBase.vQHeal < 2 &&//хилки не построены
		(
		(
		pDataHumans->vBaseHelp1 == NULL && pDataHumans->vBaseHelp2 == NULL &&// Если нет вампиров около баз
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&//мейн вал есть
		(pHumanPlayer->vBase.vBuildHeal == TRUE || pHumanPlayer->vBase.fQPosRepairBind() > (unsigned short)((double)2 / (double)MAX_HUMAN_PLAYERS * (double)vCountHumans))//Строим хилки или позиций для починки вала больше 2
		) ||
		//(
		//(pDataHumans->vBaseHelp1 != NULL && pDataHumans->vBaseHelp1 == &pHumanPlayer->vBase) ||
		//(pDataHumans->vBaseHelp2 != NULL && pDataHumans->vBaseHelp2 == &pHumanPlayer->vBase)// если один вампир у базы данного игрока или оба
		//) &&
		pHumanPlayer->vFlagBuildHeal == FALSE &&//Приказ о страительсте хилок не отпрален
		(
		//(pDataHumans->vBaseHelp1 != pDataHumans->vBaseHelp2 && pHumanPlayer->vBase.fQPosRepair() > 3) || //вампир один позиций для починки вала более 3
		//(pDataHumans->vBaseHelp1 == pDataHumans->vBaseHelp2 && pHumanPlayer->vBase.fQPosRepair() > 5)// вампиров два позиций для починки вала более 5, то есть все
		(fQPosRepairMainHuman(&pHumanPlayer->vBase) >= (unsigned short)((double)3 / (double)MAX_HUMAN_PLAYERS * (double)vCountHumans) || // * (double)(vCountVampires + vCountVampiresUser)
		pHumanPlayer->vBase.vBuildHeal == TRUE ||
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_LIFE) < 
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.7)))) &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&// вал не сломан
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId != ID_UNIT_BUILD_WALL_BROWN &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId != ID_UNIT_BUILD_WALL_YELLOW &&
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE) > 
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.6))))// у вала более 60% хп
	{
		pHumanPlayer->vFlagBuildHeal = TRUE;
		if (pHumanPlayer->vBase.vBuildHeal == TRUE)
		{
			sprintf(vBuf,"%s\0","Пополнить ману");
			if (fNewChainAction(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),CHAIN_ACTION_UP_MANA,vBuf) == TRUE);
		}
		sprintf(vBuf,"%s\0","Строим хил 2");
		if (fNewChainActionBuild(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),COMMENT_HEAL_2,ID_UNIT_BUILD_TOWER_HEAL_LVL1,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
		sprintf(vBuf,"%s\0","Строим хил 1");
		if (fNewChainActionBuild(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),COMMENT_HEAL_1,ID_UNIT_BUILD_TOWER_HEAL_LVL1,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
		sprintf(vBuf,"%s\0","Улучшаем мана рег в первой кузне");
		if (fNewChainActionResearch(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),N_RESEARCH_MANA_REG,COMMENT_FIRST_KUZNYA,vBuf) == TRUE);
		if (pHumanPlayer->vBase.vBuildHeal == FALSE)
		{
			fGetAllWood(pHumanPlayer);
		}
		pHumanPlayer->vBase.vQHeal = 2;
		pHumanPlayer->vBlockRepair = TRUE;
		pHumanPlayer->vTimeBuildHeal = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
		fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
		return TRUE;
	}
	// Прийти на помощь, если надо
	fComeToTheRescue(pHumanPlayer);
	//if (fBuildHealTower(pHumanPlayer) == TRUE) goto m1;
	/*if (pHumanPlayer->vBlockRepair == FALSE &&
		pHumanPlayer->vCountTowerWhite >= 13 &&
		fBlinkToWall(pHumanPlayer) == TRUE) goto m1;*/
	//
	/*if (pDataHumans->vFirstGold == FALSE &&
		GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 1)
	{
		pDataHumans->vFirstGold = TRUE;
	}*/
	// Если Ера 1 и голд майнов более 10 и темп цепочка есть, то добавляем темп цепочку
	if (pHumanPlayer->vCurrentEra == 1 &&
		pHumanPlayer->vBase.vQGoldMine > 10 &&
		pHumanPlayer->vTempChain)
	{
		fAddChain(pHumanPlayer,pHumanPlayer->vTempChain);
		pHumanPlayer->vTempChain = NULL;
	}
	// Ера 1 не у всех хуманов
	if (pDataHumans->vEra1All == FALSE)
	{
		// Есть ли золото
		if (pHumanPlayer->vGoldYes == FALSE &&
			GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 1)
		{
			pHumanPlayer->vGoldYes = TRUE;
		}
		else if (pHumanPlayer->vGoldYes == TRUE &&
				GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) == 0)
		{
			pHumanPlayer->vGoldYes = FALSE;
		}
		// Сказать, что я припас 2 золота на строительство храма и лесопилки
		if (pHumanPlayer->vGoldYes == TRUE &&
			pHumanPlayer->vBase.vTwoGold == FALSE)
		{
			if (GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) == 2)
			{
				pHumanPlayer->vBase.vTwoGold = TRUE;
			}
		}
		/*if (pHumanPlayer->vOneGoldImba == FALSE &&
			pDataHumans->vFirstGold == TRUE &&
			pHumanPlayer->vHelp == TRUE &&
			pDataHumans->vFlagHelp1 == TRUE &&
			pDataHumans->vFlagHelp2 == TRUE &&
			pDataHumans->vBaseHelp1 == pDataHumans->vBaseHelp2)
		{
			for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
			{
				if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer)
				{
					if (fTransferRes(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
									 pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD,
									 GetPlayerState(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD)) == FALSE);
					if (fTransferRes(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
									 pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER,
									 GetPlayerState(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER)) == FALSE);
				}
			}
			pHumanPlayer->vFlagImba = TRUE;
			pHumanPlayer->vParamPlayer.vStage = 84;
		}*/
		// (Мировой рынок)
		// Забрать золото для постройки хама и лесопилки
		if (pHumanPlayer->vBase.vTempleAndLumberHouse == FALSE &&
			pHumanPlayer->vBase.vTwoGold == FALSE &&
			pHumanPlayer->vFlagGoldTower == TRUE)// Загрейжены золотые пушки)
		{
			if (fAllGold(pHumanPlayer) >= 2 &&
				fGetAllGoldLimit2(pHumanPlayer) == TRUE)
			{
				pHumanPlayer->vBase.vTwoGold = TRUE;
				if (pHumanPlayer->vCurrentChain &&
					pHumanPlayer->vCurrentChain->vN < 52)
				{
					pHumanPlayer->vTempChain = pHumanPlayer->vCurrentChain;
					fShiftChain(pHumanPlayer,52);
					fGetAllWood(pHumanPlayer);
					sprintf(vBuf,"%s\0","Грейдим пушки в золотые");
					if (fNewChainActionUniversal(pHumanPlayer,TRUE,37,81,vBuf) == TRUE);
					sprintf(vBuf,"%s\0","Строим белые пушки и грейдим их в золотые");
					if (fNewChainActionUniversal(pHumanPlayer,TRUE,36,80,vBuf) == TRUE);
					pHumanPlayer->vBlockRepair = TRUE;
					pHumanPlayer->vBuildHram = TRUE;
					return TRUE;
				}
				return FALSE;
			}
		}
		// Отдать второй голд, человеку у которого eсть один голд
		// Храма нет, лесопилки нет, два голд нет, один голод есть
		if (pHumanPlayer->vBase.vTempleAndLumberHouse == FALSE &&
			pHumanPlayer->vBase.vTwoGold == FALSE &&
			pHumanPlayer->vGoldYes == TRUE)
		{
			// Пробегаемся по всех хуманам
			for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
			{
				// Если игрок другой, база родная, не слауер база
				if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer &&
					pHumanPlayerGlobal[pHumanPlayer->vvi].vFlagDearBase == TRUE &&
					pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vSlayerBaze == FALSE &&
					pHumanPlayerGlobal[pHumanPlayer->vvi].vOneGoldImba == TRUE)
				{
					// отдаём все золото и лес соседу
					if (fTransferRes(pHumanPlayer->vParamPlayer.vPlayer,
									 pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD,
									 GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD)) == FALSE);
					if (fTransferRes(pHumanPlayer->vParamPlayer.vPlayer,
									 pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER,
									 GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER)) == FALSE);
					pHumanPlayer->vGoldYes = FALSE;
					break;
				}
			}
		}
		// Отдать золото и лес, если напали на соседа
		// Храма нет, лесопилки нет, два голд нет, один голод есть
		if (pHumanPlayer->vBase.vTempleAndLumberHouse == FALSE &&
			pHumanPlayer->vBase.vTwoGold == FALSE &&
			pHumanPlayer->vGoldYes == TRUE)
		{
			// Пробегаемся по всех хуманам
			for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
			{
				// Если игрок другой, база родная, не слауер база, вампира видно около базы
				if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer &&
					pHumanPlayerGlobal[pHumanPlayer->vvi].vFlagDearBase == TRUE &&
					pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vSlayerBaze == FALSE &&
					(pDataHumans->vBaseHelp1 &&
					pDataHumans->vBaseHelp1 == &pHumanPlayerGlobal[pHumanPlayer->vvi].vBase) ||
					(pDataHumans->vBaseHelp2 &&
					pDataHumans->vBaseHelp2 == &pHumanPlayerGlobal[pHumanPlayer->vvi].vBase))
				{
					// отдаём все золото и лес соседу
					if (fTransferRes(pHumanPlayer->vParamPlayer.vPlayer,
									 pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD,
									 GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD)) == FALSE);
					if (fTransferRes(pHumanPlayer->vParamPlayer.vPlayer,
									 pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER,
									 GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER)) == FALSE);
					pHumanPlayer->vGoldYes = FALSE;
					break;
				}
			}
			//pHumanPlayer->vFlagImba = TRUE;
			//pHumanPlayer->vParamPlayer.vStage = 84;
		}
		// Отдать золото, если база разрушена или слаерка
		// Не храм, не лесопилка, два голда нет, один голд есть, база не родная или срауерака
		if (//pDataHumans->vFirstGold == TRUE &&
			pHumanPlayer->vBase.vTempleAndLumberHouse == FALSE &&
			pHumanPlayer->vBase.vTwoGold == FALSE &&
			pHumanPlayer->vGoldYes == TRUE &&
			(pHumanPlayer->vFlagDearBase == FALSE ||
			pHumanPlayer->vBase.vSlayerBaze == TRUE))
		{
			// Пробегаемся по всем хуманам
			for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
			{
				// Если игрок другой, база родная, не срауер
				if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer &&
					pHumanPlayerGlobal[pHumanPlayer->vvi].vFlagDearBase == TRUE &&
					pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vSlayerBaze == FALSE)
				{
					// Отдаём золото первому попавшемуся игроку
					if (fTransferRes(pHumanPlayer->vParamPlayer.vPlayer,
									 pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD,
									 GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD)) == FALSE);
					if (fTransferRes(pHumanPlayer->vParamPlayer.vPlayer,
									 pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER,
									 GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER)) == FALSE);
					pHumanPlayer->vGoldYes = FALSE;
					break;
				}
			}
			//pHumanPlayer->vFlagImba = TRUE;
			//pHumanPlayer->vParamPlayer.vStage = 84;
		}
		// Строим синий вал и 4 пушки потом их отменяем если вампы ушли
		// Храма нет, лесопилки нет, два голда нет, имба не запущена, голд есть.
		if (pHumanPlayer->vBase.vTempleAndLumberHouse == FALSE &&
			pHumanPlayer->vBase.vTwoGold == FALSE &&
			pHumanPlayer->vOneGoldImba == FALSE &&
			pHumanPlayer->vGoldYes == TRUE)
		if (GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 1)//голд есть
		{
			// Мейн вал есть, у него более 50% хп, вал фиолетовый
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
				(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE) > 
				(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.5)) &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET)
			{
				// Наша база под атакой
				if ((pDataHumans->vBaseHelp1 &&
					pDataHumans->vBaseHelp1 == &pHumanPlayer->vBase) ||
					(pDataHumans->vBaseHelp2 &&
					pDataHumans->vBaseHelp2 == &pHumanPlayer->vBase))
				{
					//if (pHumanPlayer->vParamPlayer.vTimerGetElapsed < 60 * 12)
					//{
						/*for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
						{
							if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer)
							{
								if (fTransferRes(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
												 pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER,
												 GetPlayerState(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER)) == FALSE);
							}
						}*/
						//pHumanPlayer->vFlagImba = FALSE;
					//}
					//else
					//{
						//pHumanPlayer->vFlagImba = TRUE;
					//}
					//pHumanPlayer->vParamPlayer.vStage = 84;
					//pHumanPlayer->vFlagHelp = FALSE;
					//pHumanPlayer->vStageHelp = 0;
					//pHumanPlayer->vFlagEscapeFromTheBase = FALSE;
					//pHumanPlayer->vStageEscapeFromTheBase = 0;
					sprintf(vBuf,"%s\0","Запускаем цепочку имба №1");
					if (fNewChainAction(pHumanPlayer,TRUE,54,CHAIN_ACTION_IMBA_1,vBuf) == TRUE);
					sprintf(vBuf,"%s\0","Строим 4 конуса");
					if (fNewChainActionUniversal(pHumanPlayer,TRUE,53,207,vBuf) == TRUE);
					sprintf(vBuf,"%s\0","Строим храм");
					if (fNewChainActionBuild(pHumanPlayer,TRUE,52,COMMENT_TEMPLE,ID_UNIT_BUILD_HRAM,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
					fGetAllWood(pHumanPlayer);
					pHumanPlayer->vBlockRepair = TRUE;
					pHumanPlayer->vOneGoldImba = TRUE;
					return TRUE;
				}
			}
			else
			{
				/*for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
				{
					if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer &&
						pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vSlayerBaze == FALSE)
					{
						if (fTransferRes(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
										 pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD,
										 GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD)) == FALSE);
						if (fTransferRes(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
										 pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER,
										 GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER)) == FALSE);
						pHumanPlayer->vGoldYes = FALSE;
						break;
					}
				}*/
			}
		}
		/*else
		{
			pHumanPlayer->vGoldYes = FALSE;
		}*/
	}
	if (pHumanPlayer->vBlockRepair == FALSE &&
		pHumanPlayer->vBase.vTwoGold == TRUE &&
		(pDataHumans->vBaseHelp1 == &pHumanPlayer->vBase ||
		pDataHumans->vBaseHelp2 == &pHumanPlayer->vBase))
	{
		pHumanPlayer->vBlockRepair = TRUE;
	}
	if (pHumanPlayer->vCurrentChain &&
		(pHumanPlayer->vCurrentChain->vN < 52 || pHumanPlayer->vCurrentChain->vN > pHumanPlayer->MAX_Q_FOR_MASS_CHAINS - 500) &&
		pHumanPlayer->vBase.vTempleAndLumberHouse == FALSE &&
		pHumanPlayer->vBase.vTwoGold == TRUE &&
		pHumanPlayer->vFlagDearBase == TRUE &&
		pHumanPlayer->vBuildHram == FALSE)
	{
		pHumanPlayer->vTempChain = pHumanPlayer->vCurrentChain;
		fShiftChain(pHumanPlayer,52);
		if (pHumanPlayer->vParamPlayer.vTimerGetElapsed < 12 * 60)
		{
			fGetAllWood(pHumanPlayer);
		}
		sprintf(vBuf,"%s\0","Грейдим пушки в золотые");
		if (fNewChainActionUniversal(pHumanPlayer,TRUE,37,81,vBuf) == TRUE);
		sprintf(vBuf,"%s\0","Строим белые пушки и грейдим их в золотые");
		if (fNewChainActionUniversal(pHumanPlayer,TRUE,36,80,vBuf) == TRUE);
		pHumanPlayer->vBlockRepair = TRUE;
		pHumanPlayer->vBuildHram = TRUE;
	}
	return FALSE;
}

void fOldStages(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return;
	if ((pHumanPlayer->vFlagRepair == FALSE || pHumanPlayer->vBlockRepair == TRUE) &&
		pHumanPlayer->vFlagDearBase == TRUE)
	if (pHumanPlayer->vCurrentEra == 0)
	//if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_UNIVERSAL)
	if (pHumanPlayer->vStage >= 0 && pHumanPlayer->vStage <= 101)
	{
		switch(pHumanPlayer->vStage)
		{
		case 0:
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
			/*if (fCheckCreateIdDataUnit((unsigned short)pHumanPlayer->vParamPlayer.vAI) == TRUE)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;*/
		case 1:
			// Находим позицию первого домика на своей базе
			pHumanPlayer->vInt3 = vMapBases.fFindHouse(&pHumanPlayer->vBase);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
			/*if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_MAIN_HUMAN1,COMMENT_MAIN_HUMAN) == true ||
				pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_MAIN_HUMAN2,COMMENT_MAIN_HUMAN) == true)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;*/
		case 2:
			// Блинкаемся к первому домику
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 3:
			// Строим первый домик
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_DOM) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 4:
			// Присваеваем коментарий первому домику и устанавливаем флаг на ближайшее дерево
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_DOM,COMMENT_FIRST_DOM) == true)
			{
				fSetFlagUnit(&pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM],&pHumanPlayer->vParamPlayer);
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 5:
			// Тренеруем 6 рабочих
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].vIdForComments == COMMENT_FIRST_DOM)
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].pDataUnit,ID_UNIT_WORKER,6) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 6:
			// Находим позицию для первого тента на специальном радиусе от начала базы, где можно дострелить рикошетом, а также в не зоны пушек
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_TENT,20,120,FALSE,FALSE,FALSE);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 7:
			// Блинкаемся к первому тенту
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 8:
			// Строим первый тент
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_TENT) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 9:
			// Комментируем первый тент
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_TENT,COMMENT_FIRST_TENT) == true)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 10:
			// Находим позицию второго домика и т.д. и т.п.
			pHumanPlayer->vInt3 = vMapBases.fFindHouse(&pHumanPlayer->vBase);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 11:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 12:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_DOM) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 13:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_DOM,COMMENT_SECOND_DOM) == true)
			{
				fSetFlagUnit(&pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_DOM],&pHumanPlayer->vParamPlayer);
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 14:
			pHumanPlayer->vInt3 = vMapBases.fFindHouse(&pHumanPlayer->vBase);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 15:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 16:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_DOM].vIdForComments == COMMENT_SECOND_DOM)
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_DOM].pDataUnit,ID_UNIT_WORKER,6) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 17:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_DOM) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 18:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_DOM,COMMENT_THIRD_DOM) == true)
			{
				fSetFlagUnit(&pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_DOM],&pHumanPlayer->vParamPlayer);
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 19:
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_TENT,20,120,FALSE,FALSE,FALSE);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 20:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 21:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_TENT) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 22:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_DOM].vIdForComments == COMMENT_THIRD_DOM)
			{
				if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_DOM].pDataUnit,ID_UNIT_WORKER,6) == 1)
					pHumanPlayer->vParamPlayer.vStage++;
			}
			else
			{
				pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_DOM,COMMENT_THIRD_DOM);
			}
			goto m1;
		case 23:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_TENT,COMMENT_SECOND_TENT) == true)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 24:
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_TENT,20,120,FALSE,FALSE,FALSE);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 25:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 26:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_TENT) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 27:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_TENT,COMMENT_THIRD_TENT) == true)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 28:
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_TENT,20,120,FALSE,FALSE,FALSE);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 29:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 30:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_TENT) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 31:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_TENT,COMMENT_FOURTH_TENT) == true)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 32:
			// Если тип базы хумана со слаеркой в начале, то строим слаерку в начале. =)
			if (pHumanPlayer->vBase.vSlayerBaze == FALSE)
			{
				pHumanPlayer->vParamPlayer.vStage = 39;
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage = 39;
			}
			goto m1;
		case 33:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].vIdForComments == COMMENT_TAVERN_SLAYER)
			{
				pHumanPlayer->vParamPlayer.vStage = 201;
				goto m1;
			}
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_SLAYER_TAVERN,20,120,FALSE,FALSE,FALSE);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 34:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 35:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_SLAYER_TAVERN) == 1)
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].vIdForComments == COMMENT_TAVERN_SLAYER)
			{
				pHumanPlayer->vParamPlayer.vStage += 2;
				goto m1;
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			goto m1;
		case 36:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_SLAYER_TAVERN,COMMENT_TAVERN_SLAYER) == true)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage = 34;
			}
			goto m1;
		case 37:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].vIdForComments != COMMENT_TAVERN_SLAYER)
			{
				pHumanPlayer->vParamPlayer.vStage--;
				goto m1;
			}
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].vIdForComments == COMMENT_SLAYER)
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit,ID_UNIT_SLAYER1,1) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 38:
			// Если тип базы не слаерка в начале
			if (pHumanPlayer->vBase.vSlayerBaze == FALSE)
			{
				pHumanPlayer->vParamPlayer.vStage = 201;
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage = 54;
			}
			goto m1;
		case 39:
			pHumanPlayer->vInt3 = vMapBases.fFindHouse(&pHumanPlayer->vBase);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 40:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 41:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_DOM) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 42:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_DOM,COMMENT_FOURTH_DOM) == true)
			{
				fSetFlagUnit(&pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_DOM],&pHumanPlayer->vParamPlayer);
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 43:
			pHumanPlayer->vInt3 = vMapBases.fFindHouse(&pHumanPlayer->vBase);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 44:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 45:
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_DOM].pDataUnit,ID_UNIT_WORKER,1) == 1);
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 46:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_DOM) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 47:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_DOM,COMMENT_FIFTH_DOM) == true)
			{
				fSetFlagUnit(&pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIFTH_DOM],&pHumanPlayer->vParamPlayer);
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 48:
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIFTH_DOM].pDataUnit,ID_UNIT_WORKER,5) == 1);
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 49:
			pHumanPlayer->vInt3 = vMapBases.fFindHouse(&pHumanPlayer->vBase);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 50:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 51:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_DOM) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 52:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_DOM,COMMENT_SIXTH_DOM) == true)
			{
				fSetFlagUnit(&pHumanPlayer->vParamPlayer.vUnit[COMMENT_SIXTH_DOM],&pHumanPlayer->vParamPlayer);
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 53:
			// Если тип базы не слаерка в начале
			if (pHumanPlayer->vBase.vSlayerBaze == FALSE)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage = 60;
			}
			goto m1;
		case 54:
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_KUZNYA,20,120,FALSE,FALSE,FALSE);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 55:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 56:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA)
			{
				pHumanPlayer->vParamPlayer.vStage = 58;
				goto m1;
			}
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_KUZNYA) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 57:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_KUZNYA,COMMENT_FIRST_KUZNYA) == true)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			//else
			//{
			//	pHumanPlayer->vParamPlayer.vStage = 54;
			//}
			goto m1;
		case 58:
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_WALL_BROWN,0,0,FALSE,TRUE,FALSE);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 59:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 60:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_TENT].vIdForComments == COMMENT_FIRST_TENT &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_TENT].pDataUnit->vIdTrain == ID_UNIT_BUILD_GRADE_TENT ||
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_TENT].pDataUnit->vId == ID_UNIT_BUILD_GRADE_TENT))
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_TENT].pDataUnit,ID_UNIT_BUILD_GRADE_TENT,1) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 61:
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 62:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_TENT].vIdForComments == COMMENT_SECOND_TENT &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_TENT].pDataUnit->vIdTrain == ID_UNIT_BUILD_GRADE_TENT ||
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_TENT].pDataUnit->vId == ID_UNIT_BUILD_GRADE_TENT))
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_TENT].pDataUnit,ID_UNIT_BUILD_GRADE_TENT,1) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 63:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_TENT].vIdForComments == COMMENT_THIRD_TENT &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_TENT].pDataUnit->vIdTrain == ID_UNIT_BUILD_GRADE_TENT ||
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_TENT].pDataUnit->vId == ID_UNIT_BUILD_GRADE_TENT))
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_TENT].pDataUnit,ID_UNIT_BUILD_GRADE_TENT,1) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 64:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].vIdForComments == COMMENT_FOURTH_TENT &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].pDataUnit->vIdTrain == ID_UNIT_BUILD_GRADE_TENT ||
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].pDataUnit->vId == ID_UNIT_BUILD_GRADE_TENT))
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].pDataUnit,ID_UNIT_BUILD_GRADE_TENT,1) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 65:
			if (pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_WORKER) >= 48)
			{	
				pHumanPlayer->vParamPlayer.vStage++;
			}
			else
			{
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].pDataUnit,ID_UNIT_WORKER,1);
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_SECOND_DOM].pDataUnit,ID_UNIT_WORKER,1);
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_THIRD_DOM].pDataUnit,ID_UNIT_WORKER,1);
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_DOM].pDataUnit,ID_UNIT_WORKER,1);
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIFTH_DOM].pDataUnit,ID_UNIT_WORKER,1);
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_SIXTH_DOM].pDataUnit,ID_UNIT_WORKER,1);			
			}
			goto m1;
		case 66:
			pHumanPlayer->vActionStackForUnits.fSetCommentAll(COMMENT_NEW_UNIT,ID_UNIT_WORKER,COMMENT_BUSY_UNIT);
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 67:
			// Если тип базы не слаерка в начале
			if (pHumanPlayer->vBase.vSlayerBaze == FALSE)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			else
			{
				if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].vIdForComments == COMMENT_TAVERN_SLAYER)
				{
					pHumanPlayer->vParamPlayer.vStage++;
				}
				else
				{
					pHumanPlayer->vParamPlayer.vStage = 33;
				}
			}
			goto m1;
		case 68:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_WALL_BROWN) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 69:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_WALL_BROWN,COMMENT_MAIN_WALL) == true)
			{
				pHumanPlayer->vWallCreated = TRUE;
				pHumanPlayer->vBase.vWallCreated = TRUE;
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
				pHumanPlayer->vInt3 = pHumanPlayer->vBase.vRepairPos[3].vInt3;
				if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1);
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 70:
			// Если тип базы не слаерка в начале
			if (pHumanPlayer->vBase.vSlayerBaze == FALSE)
			{
				pHumanPlayer->vParamPlayer.vStage = 80;
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 71:
			// Слаерам качаем лес 1
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_LES1] == FALSE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				if (fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_LES1) == 1)
					pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 72:
			// Найти безопасную зону
			pHumanPlayer->vInt3 = vMapBases.fFindPosSafeZone(&pHumanPlayer->vBase);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage = 74;
			}
			goto m1;
		case 73:
			// Зафиксировать хумана слаера
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->PermissionMove == TRUE)
			{
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->PermissionMove = FALSE;
			}
			// Бликнуться в безопасную зону
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_BLINK) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 74:
			// Слаерам качаем лес 2
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_LES1] == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				if (fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_LES2) == 1)
					pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 75:
			// Слаерам качаем лес 3
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_LES2] == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				if (fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_LES3) == 1)
					pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 76:
			// Слаерам качаем лес спид 1
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_LES3] == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				if (fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_LES_SPEED1) == 1)
					pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 77:
			// Слаерам качаем броню слаеру
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_LES_SPEED1] == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				if (fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_SLAYER_ARMOR1) == 1)
					pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 78:
			// Слаерам качаем апгрейд слаеру
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_SLAYER_ARMOR1] == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				if (fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_SLAYER_UPGRADE1) == 1)
					pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 79:
			// Если тип базы не слаерка в начале
			if (pHumanPlayer->vBase.vSlayerBaze == FALSE)
			{
				pHumanPlayer->vParamPlayer.vStage = 83;
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 80:
			if (pHumanPlayer->vBase.vSlayerBaze == TRUE &&
				pHumanPlayer->vParamPlayer.vTimerGetElapsed < 60 * 2.5)
			{
				if (pHumanPlayer->vFlagSafeZone == FALSE)
				{
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3 = vMapBases.fFindPosSafeZone(&pHumanPlayer->vBase);
					if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3 != vSizeMap &&
						fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vIdDataUnit,
									pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3,ACTION_GO) == 1)
					{
						pHumanPlayer->vFlagSafeZone = TRUE;
					}
				}
				goto m1;
			}
			// Обновляем постройку кузницы
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Postroeno == FALSE)
			{
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->fGetPostroeno();
			}
			// Обновляем постройку вала
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == FALSE)
			{
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->fGetPostroeno();
			}
			fAddDataUnitInRange(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit);
			// Сначала грейдим улучшение на хп вала
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_GEM1] == FALSE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Postroeno == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_GEM1);
			}
			// Потом грейдим вал до жолтого
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == TRUE ||
				pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_GEM1] == TRUE) &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_BROWN)
			{
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit,ID_UNIT_BUILD_WALL_YELLOW,1);
			}
			// Потом грейдим вал до фиолетового
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_YELLOW)
			{
				if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit,ID_UNIT_BUILD_WALL_VIOLET,1) == TRUE)
				{
					pHumanPlayer->vFlagBuildWhiteTower = TRUE;
				}
			}
			if (pHumanPlayer->vFlagBuildWhiteTower == TRUE &&
				pHumanPlayer->vTimeCreateTower != 0 &&
				pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeCreateTower > 10)
			{	
				pHumanPlayer->vFlagPos = FALSE;
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vLastAction = ACTION_BUILD;
				//fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
				pHumanPlayer->vTimeCreateTower = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
			}
			if (pHumanPlayer->vFlagBuildWhiteTower == FALSE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == TRUE &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET ||
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vIdTrain == ID_UNIT_BUILD_WALL_VIOLET))
			{
				pHumanPlayer->vFlagBuildWhiteTower = TRUE;
			}
			// Мы далеко от вала или последнее действие ждём
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vLastAction == ACTION_WAITING ||
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit &&
				(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vLastAction != ACTION_UNKNOWN &&
				fG(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.X,
				   pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.Y,
				   pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->LastCoordinates.X,
				   pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->LastCoordinates.Y) > 128 * 10))))
			{
				pHumanPlayer->vFlagPos = FALSE;
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vLastAction = ACTION_BUILD;
			}
			// Потом строим пушки
			if (pHumanPlayer->vFlagBuildWhiteTower == TRUE &&
				pHumanPlayer->vFlagPos == FALSE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vLastAction == ACTION_BUILD)
			{
				pHumanPlayer->vCountTowerWhite = pHumanPlayer->vActionStackForUnitsTower.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_WHITE);
				//pHumanPlayer->vCountTowerWhite++;
				pHumanPlayer->vBase.vQFirstTower = pHumanPlayer->vCountTowerWhite + pHumanPlayer->vActionStackForUnitsTower.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_GOLD);
				if (pHumanPlayer->vBase.vQFirstTower >= 4)
				{
					pHumanPlayer->vBase.vSlayerBaze = FALSE;
				}
				switch(pHumanPlayer->vBase.vQFirstTower)
				{
				case 0:
				case 1:
				case 2:
				case 3:
				case 4:
				case 5:
				case 6:
				case 7:
				case 8:
				case 9:
				case 10:
				case 11:
				case 12:
				case 13:
				case 14:
				case 15:
				case 16:
				case 17:
				case 18:
				case 19:
				case 20:
					pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_TOWER_WHITE,0,120,FALSE,TRUE,TRUE);
					if (pHumanPlayer->vInt3 == vSizeMap)
					{
						pHumanPlayer->vFlagGreadeGoldTower = TRUE;
						pHumanPlayer->vParamPlayer.vStage++;
						goto m1;
					}
					pHumanPlayer->vFlagPos = TRUE;
					pHumanPlayer->vTimeCreateTower = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
					fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
					break;
				case 21:
					if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
						pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == TRUE &&
						(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET ||
						pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vIdTrain == ID_UNIT_BUILD_WALL_VIOLET))
					{
						pHumanPlayer->vActionStackForUnits.fSetCommentAll(COMMENT_NEW_UNIT,ID_UNIT_BUILD_TOWER_WHITE,COMMENT_BUSY_UNIT);
						pHumanPlayer->vFlagGreadeGoldTower = TRUE;
						pHumanPlayer->vParamPlayer.vStage++;
					}
					goto m1;
				}
			}
			// Идем к месту строительства пушки
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vLastAction == ACTION_BUILD &&
				pHumanPlayer->vFlagBuildWhiteTower == TRUE &&
				pHumanPlayer->vFlagPos == TRUE)
			{
				/*pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit);
				if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vActionFinish == 0 &&
					pHumanPlayer->vIdOrder == ID_UNIT_BUILD_TOWER_WHITE &&
					(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
					(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE) >
					(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.8))))
				{
					fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
				}*/
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vLastAction = ACTION_UNKNOWN;
				fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO);
			}
			// Строим пушку
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vLastAction == ACTION_GO ||
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vLastAction == ACTION_BLINK)
			{
				if (fBuildAction(pHumanPlayer,
					             pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,
							     pHumanPlayer->vInt3,
							     ID_UNIT_BUILD_TOWER_WHITE) == 1)
				{
					pHumanPlayer->vFlagPos = FALSE;
				}
				else
				{
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vLastAction = ACTION_BUILD;
					vMapBases.fFreeZoneTower(pHumanPlayer->vInt3);
					pHumanPlayer->vFlagPos = FALSE;
				}
			}
				fTrainActionCountUnits(pHumanPlayer,
									   COMMENT_NEW_UNIT,
									   ID_UNIT_BUILD_TOWER_WHITE,
									   ID_UNIT_BUILD_TOWER_GOLD,
									   pHumanPlayer->vCountTowerWhite,
									   &pHumanPlayer->vActionStackForUnitsTower);
			goto m1;
		case 81:
			// Грейдить белые пушки до золотых
			if (pHumanPlayer->vFlagGreadeGoldTower == TRUE)
			if (fUpgradeUnit(pHumanPlayer,
				             ID_UNIT_BUILD_TOWER_WHITE,
							 ID_UNIT_BUILD_TOWER_GOLD,
							 FALSE,
							 &pHumanPlayer->vActionStackForUnitsTower) == TRUE);
				/*fTrainActionCountUnits(pHumanPlayer,
									   COMMENT_NEW_UNIT,
									   ID_UNIT_BUILD_TOWER_WHITE,
									   ID_UNIT_BUILD_TOWER_GOLD,
									   pHumanPlayer->vCountTowerWhite,
									   &pHumanPlayer->vActionStackForUnitsTower);*/
			if (pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_GOLD) >= (pHumanPlayer->vCountTowerWhite))
			{	
				pHumanPlayer->vActionStackForUnits.fSetCommentAll(COMMENT_NEW_UNIT,ID_UNIT_BUILD_TOWER_GOLD,COMMENT_BUSY_UNIT);
				//pHumanPlayer->vFlagRepair = TRUE;
				pHumanPlayer->vParamPlayer.vStage++;
				pHumanPlayer->vFlagGoldTower = TRUE;
				goto m1;
			}
			if (pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_WHITE) == pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_GOLD))
			{
				pHumanPlayer->vParamPlayer.vStage--;
			}
			goto m1;
		case 82:
			// Если тип базы не слаерка в начале
			if (pHumanPlayer->vBase.vSlayerBaze == FALSE)
			{
				pHumanPlayer->vParamPlayer.vStage = 33;
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage = 33;
			}
			goto m1;
		case 83:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TEMPLE].vIdForComments == COMMENT_TEMPLE)
			{
				pHumanPlayer->vFlagImba = TRUE;
				pHumanPlayer->vParamPlayer.vStage = 88;
				goto m1;
			}
			// Грейдим хп вала
			/*if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_GEM1] == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Postroeno == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_GEM2);
			}
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_GEM2] == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Postroeno == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_GEM3);
			}*/
			if (GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 1 &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
				(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE) > 
				(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.5)))
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 84:
			if (pHumanPlayer->vBase.vSlayerBaze == TRUE)
			{
				pHumanPlayer->vBase.vSlayerBaze = FALSE;
			}
			fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_HRAM,20,120,FALSE,FALSE,FALSE);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vBlockRepair = TRUE;
				pHumanPlayer->vFlagRepair = FALSE;
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 85:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_BLINK) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 86:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_HRAM) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 87:
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_HRAM,COMMENT_TEMPLE) == true)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 88:
			if (pHumanPlayer->vBlockRepair == TRUE) pHumanPlayer->vBlockRepair = FALSE;
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit,ID_UNIT_BUILD_WALL_BLUE,1) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 89:
			// Засекаем время
			if (pHumanPlayer->vFlagImba == TRUE)
			{
				pHumanPlayer->vTimeImba = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
			}
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 90:
			if (pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_KONUS) >= 2)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			else
			{
				// Грейдим два конуса в не зоны доступа
				if (fUpgradeUnit(pHumanPlayer,ID_UNIT_BUILD_TOWER_GOLD,ID_UNIT_BUILD_TOWER_KONUS,FALSE,&pHumanPlayer->vActionStackForUnits) == TRUE);
			}
			goto m1;
		case 91:
			// Грейдим красные пушки в не зоны доступа
			if (fUpgradeUnit(pHumanPlayer,ID_UNIT_BUILD_TOWER_KONUS,ID_UNIT_BUILD_TOWER_FIRE_LVL1,FALSE,&pHumanPlayer->vActionStackForUnits) == TRUE);
			if (pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_FIRE_LVL1) >= 2)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 92:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRE_1].vIdForComments == COMMENT_FIRE_1)
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_BUSY_UNIT,ID_UNIT_BUILD_TOWER_FIRE_LVL1,COMMENT_FIRE_1) == true)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 93:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRE_2].vIdForComments == COMMENT_FIRE_2)
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_BUSY_UNIT,ID_UNIT_BUILD_TOWER_FIRE_LVL1,COMMENT_FIRE_2) == true)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 94:
			if (fAllWood(pHumanPlayer) >= 45000)
			{
				pHumanPlayer->vFlagImba = FALSE;
			}
			if (pHumanPlayer->vFlagImba == TRUE &&
				(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeImba > 25) &&
				(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeAttackWall > 10))
			{
				// Отменяем строительство вала и двух пушек красных
				fAddDataUnitInRange(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit);
				fCancel_1(pHumanPlayer,0);
				pHumanPlayer->vTimeImba = FALSE;
				if (fAllWood(pHumanPlayer) >= 20000 &&
					fGetAllWood(pHumanPlayer) == TRUE)
				{
					pHumanPlayer->vParamPlayer.vStage++;
				}
				else
				{
					pHumanPlayer->vParamPlayer.vStage = 83;
				}
			}
			if (pHumanPlayer->vFlagImba == FALSE)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 95:
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].pDataUnit,ID_UNIT_BUILD_LESOPILKA1,1) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 96:
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_GOLD_MINE_WHITE,10,120,TRUE,FALSE,FALSE);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 97:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_BLINK) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 98:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].vIdForComments == COMMENT_FIRST_DOM &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].pDataUnit->vId != ID_UNIT_BUILD_LESOPILKA1)
				goto m1;
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_GOLD_MINE_WHITE) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 99:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				if (fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_HP_WORKERS) == 1)
					pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 100:
			if (pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
				pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_BLUE)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET)
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit,ID_UNIT_BUILD_WALL_BLUE,1) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 101:
			pHumanPlayer->vCurrentEra = pHumanPlayer->vNextEra;
			goto m1;
		}
	}
	//if (pHumanPlayer->vFlagRepair == FALSE)
	if (pHumanPlayer->vCurrentEra == 1)
	if (pHumanPlayer->vStage >= 101 && pHumanPlayer->vStage <= 200)
	{
		switch (pHumanPlayer->vStage)
		{
		case 101:
			if (fCheckRes(pHumanPlayer,1,3000) == TRUE &&
				fDeto(pHumanPlayer,ID_UNIT_WORKER,4,&pHumanPlayer->vActionStackForUnitsWorkers) == TRUE &&
				fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].pDataUnit,ID_UNIT_URSA,1) == 1)
			{
				if (pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_URSA) >= 12)
				{
					pHumanPlayer->vParamPlayer.vStage = 106;
				}
			}
			// Надо паралельно строить голд майны
			if (fCheckRes(pHumanPlayer,0,20000) == TRUE)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 102:
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,ID_UNIT_BUILD_GOLD_MINE_WHITE,10,120,TRUE,FALSE,FALSE);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 103:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_BLINK) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 104:
			if (fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ID_UNIT_BUILD_GOLD_MINE_WHITE) == 1)
				pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 105:
			if (pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
				pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_BLUE &&
				pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_GOLD_MINE_WHITE) >= 2)
			{
				pHumanPlayer->vParamPlayer.vStage = 106;
				pHumanPlayer->vBase.vQGoldMine++;
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage = 101;
			}
			if (pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_GOLD_MINE_WHITE) >= 10)
			{
				pHumanPlayer->vParamPlayer.vStage = 107;
			}
			goto m1;
		case 106:
			if (pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL)
			{
				if (pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_GREEN)
				{
					pHumanPlayer->vParamPlayer.vStage = 105;
					goto m1;
				}
				fAddDataUnitInRange(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit);
				if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit,ID_UNIT_BUILD_WALL_GREEN,1) == 1)
					pHumanPlayer->vParamPlayer.vStage = 105;
			}
			goto m1;
		case 107:
			pHumanPlayer->vCurrentEra = pHumanPlayer->vNextEra;
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		}
	}
m1:;
}

void fActionsHuman(HumanPlayer *pHumanPlayer)
{
	pHumanPlayer->vStage = pHumanPlayer->vParamPlayer.vStage;
	// Раз в секунду
	if (pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeForOneSecond >= 1)
	{
		// Засекаем время
		pHumanPlayer->vTimeForOneSecond = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
		// Проверяем эру два
		fCheckEra2All(pHumanPlayer);
		// Проверяем храм и лесопилку
		fCheckTempleAndLumberHouse(pHumanPlayer);
		// Не у всех хуманов эра 1
		if (pDataHumans->vEra1All == FALSE)
		{
			// Продаём золото
			fSaleGold(pHumanPlayer);
			// Даём золото
			fGiveAwayGold(pHumanPlayer);
		}
		/*if (pHumanPlayer->vCurrentEra == 0 &&
			pHumanPlayer->vBase.vQHeal >= 2)
		{
			pHumanPlayer->vFlagBuildHeal = FALSE;
		}*/
		// Управляем рабочими
		if (pHumanPlayer->vCurrentEra == 0) fWorkers(pHumanPlayer);
		// Управляем урасами
		fFurbolgs(pHumanPlayer);
		// Проверяем завершения иследований
		pHumanPlayer->vActionStackForUnitsResearch.fGetResearchFinish();
		// Управляем пушками
		if (fStackAttack(pHumanPlayer,&pHumanPlayer->vActionStackForUnitsTower,ID_UNIT_GRIVE) == TRUE) goto m8;
		if (fStackAttack(pHumanPlayer,&pHumanPlayer->vActionStackForUnitsTower,ID_UNIT_TINI) == TRUE) goto m8;
		if (fStackAttack(pHumanPlayer,&pHumanPlayer->vActionStackForUnitsTower,ID_UNIT_FIRE_INFERNAL) == TRUE) goto m8;
		if (fStackAttack(pHumanPlayer,&pHumanPlayer->vActionStackForUnitsTower,ID_UNIT_INFERNAL) == TRUE) goto m8;
		//if (fTowersAttack(pHumanPlayer,ID_UNIT_GRIVE) == TRUE) goto m8;
		//if (fTowersAttack(pHumanPlayer,ID_UNIT_TINI) == TRUE) goto m8;
		//if (fTowersAttack(pHumanPlayer,ID_UNIT_FIRE_INFERNAL) == TRUE) goto m8;
		//if (fTowersAttack(pHumanPlayer,ID_UNIT_INFERNAL) == TRUE) goto m8;
m8:;
	}
	// Цепочка есть, цепочка строительство, фаза строительства 304
	if (pHumanPlayer->vCurrentChain &&
		pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_BUILD &&
		pHumanPlayer->vParamPlayer.vStage == 304)
	{
		if (fIsVampireNearby(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit,pHumanPlayer) == FALSE)
		{
			goto m15;
		}
	}
	//pHumanPlayer->vParamPlayer.vBusy = TRUE;
	// Сигнал о помощи (да, нет)
	fASignalForHelp(pHumanPlayer);
	// Побег с базы (да, нет)
	if (fEscapeFromTheBase(pHumanPlayer) == TRUE) goto m15;
	
	if (fActionsHuman_Era0(pHumanPlayer) == TRUE) goto m1;
	// Строительство, развитие
m15:;
	fOldStages(pHumanPlayer);
	
	if (pHumanPlayer->vFlagDearBase == TRUE)
	if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction != CHAIN_ACTION_UNIVERSAL)
	if (pHumanPlayer->vStage >= 300 && pHumanPlayer->vStage <= 399)
	{
		if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_BUILD)
		switch(pHumanPlayer->vStage)
		{
		case 300:
			if (pHumanPlayer->vCurrentChain->vCommentUnit == COMMENT_MAIN_HUMAN &&
				pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vHelping == TRUE &&
				pHumanPlayer->vBlockRepair == FALSE)
			{
				goto m1;
			}
			if (pHumanPlayer->vCurrentChain->vComment != COMMENT_BUSY_UNIT &&
				pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vComment].vIdForComments == pHumanPlayer->vCurrentChain->vComment)
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage = 399;
				goto m1;
			}
			pHumanPlayer->vInt3 = vMapBases.fFindPosBuild(&pHumanPlayer->vBase,pHumanPlayer->vCurrentChain->vId);
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				pHumanPlayer->vRect7.vX1 = fConvertIToX(pHumanPlayer->vInt3);
				pHumanPlayer->vRect7.vY1 = fConvertIToY(pHumanPlayer->vInt3);
				pHumanPlayer->vRect7.vDiff = fRadiusToDiff(fRadius_Unit(pHumanPlayer->vCurrentChain->vId));
				pHumanPlayer->vRect7.vX2 = pHumanPlayer->vRect7.vX1 + pHumanPlayer->vRect7.vDiff - 1;
				pHumanPlayer->vRect7.vY2 = pHumanPlayer->vRect7.vY1 + pHumanPlayer->vRect7.vDiff - 1;
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vId);
				pHumanPlayer->vParamPlayer.vStage++;
			}
			else
			{
				if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vBoolTimeGoBuild == FALSE)
				{
					pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vTimeGoBuild = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
					pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vBoolTimeGoBuild = TRUE;
				}
				else
				{
					pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vBoolTimeGoBuild = FALSE;
					goto m1;
				}
				if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,pHumanPlayer->vCurrentChain->vId,pHumanPlayer->vCurrentChain->vComment) == true)
				{
					pHumanPlayer->vCurrentChain->vComplite = TRUE;
					pHumanPlayer->vParamPlayer.vStage++;
					pHumanPlayer->vTimeBuild = 0;
					goto m1;
				}
				if (pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vTimeGoBuild > 35)
				{
					//pHumanPlayer->vCurrentChain->vComplite = TRUE;
					//pHumanPlayer->vParamPlayer.vStage = 399;
					pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vParamPlayer.vStage;
				}
				goto m1;
			}
			goto m1;
		case 301:
			if (pHumanPlayer->vCurrentChain->vCommentUnit == COMMENT_MAIN_HUMAN &&
				pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vHelping == TRUE &&
				pHumanPlayer->vBlockRepair == FALSE)
			{
				pHumanPlayer->vParamPlayer.vStage = 300;
				goto m1;
			}
			pHumanPlayer->pDataUnit = fDataUnitInt3(pHumanPlayer->vInt3,HUMANS);
			if (pHumanPlayer->pDataUnit == NULL ||
				(pHumanPlayer->pDataUnit &&
				pHumanPlayer->pDataUnit->vIdDataUnit == pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vId))
			{
				if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
				{
					pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vTimeGoTo = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
					pHumanPlayer->vParamPlayer.vStage++;
				}
			}
			else
			{
				pHumanPlayer->vParamPlayer.vStage = 300;
			}
			goto m1;
		case 302:
			if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vActionFinish == 1)
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vTimeGoTo > 35)
			{
				pHumanPlayer->vParamPlayer.vStage = 300;
				goto m1;
			}
			goto m1;
		case 303:
			/*if (pHumanPlayer->vTimeBuild != 0 &&
				pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeBuild > 10)
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage = 399;
				goto m1;
			}*/
			pHumanPlayer->vResult = fBuildAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vId,pHumanPlayer->vInt3,pHumanPlayer->vCurrentChain->vId);
			if (pHumanPlayer->vResult == 1)
			{
				pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vTimeGoBuild = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
				pHumanPlayer->vParamPlayer.vStage++;
			}
			else if (pHumanPlayer->vResult == 0)
			{
				for (pHumanPlayer->vRect7.vvj2 = pHumanPlayer->vRect7.vY1; pHumanPlayer->vRect7.vvj2 <= pHumanPlayer->vRect7.vY2; pHumanPlayer->vRect7.vvj2++)
				{
					for (pHumanPlayer->vRect7.vvi2 = pHumanPlayer->vRect7.vX1; pHumanPlayer->vRect7.vvi2 <= pHumanPlayer->vRect7.vX2; pHumanPlayer->vRect7.vvi2++)
					{
						pHumanPlayer->pDataUnit = fDataUnitInt3(fConvertXYToI(pHumanPlayer->vRect7.vvi2,pHumanPlayer->vRect7.vvj2),HUMANS);
						if (pHumanPlayer->pDataUnit &&
							pHumanPlayer->pDataUnit->vId == ID_UNIT_WORKER)
						{
							if (IssuePointOrderById(pHumanPlayer->pDataUnit->WhichUnit,
													ID_ORDER_DETONATE,
													pHumanPlayer->pDataUnit->LastCoordinates.X,
													pHumanPlayer->pDataUnit->LastCoordinates.Y) == TRUE)
							{
								//
							}
						}
					}
				}
				pHumanPlayer->vParamPlayer.vStage = 301;
			}
			goto m1;
		case 304:
			if (//pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vComment].vIdForComments == pHumanPlayer->vCurrentChain->vComment ||
				pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,pHumanPlayer->vCurrentChain->vId,pHumanPlayer->vCurrentChain->vComment) == true)
			{
				/*if (pHumanPlayer->vCurrentChain->vId == ID_UNIT_BUILD_TOWER_HEAL_LVL1)
				{
					pHumanPlayer->vQHeal++;
				}*/
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage++;
				pHumanPlayer->vTimeBuild = 0;
				goto m1;
			}
			/*if (pHumanPlayer->vCurrentChain->vComment != COMMENT_BUSY_UNIT &&
				pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vComment].vIdForComments == pHumanPlayer->vCurrentChain->vComment)
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage = 399;
				goto m1;
			}*/
			if (pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vTimeGoBuild > 35)
			{
				if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vActionFinish == 1 &&
					fGoToAction(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vId,
								fJumpBack(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit),
								ACTION_GO) == 1)
				{
					pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vTimeGoBuild += 2;
					goto m1;
				}
				fAddDataUnitInRange(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit);
				pHumanPlayer->vParamPlayer.vStage = 300;
				goto m1;
			}
			goto m1;
		}
		if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_TO_WAIT_BUILD)
		switch(pHumanPlayer->vStage)
		{
		case 300:
			if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vIdForComments == pHumanPlayer->vCurrentChain->vCommentUnit &&
				(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->Postroeno == TRUE ||
				fCompliteBuild(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit,pHumanPlayer->vParamPlayer.vTimerGetElapsed) == TRUE))
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		}
		if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_TRAIN)
		switch(pHumanPlayer->vStage)
		{
		case 300:
			if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vIdForComments == pHumanPlayer->vCurrentChain->vCommentUnit)
			{
				if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit,
								 pHumanPlayer->vCurrentChain->vId,pHumanPlayer->vCurrentChain->vQTrain) == 1)
				{
					pHumanPlayer->vCurrentChain->vComplite = TRUE;
					pHumanPlayer->vParamPlayer.vStage++;
					goto m1;
				}
			}
			else
			{
				pHumanPlayer->vCurrentChain = pHumanPlayer->vForerunnerChainTemp;
				pHumanPlayer->vMassChains[pHumanPlayer->vCurrentChain->vN] = FALSE;
				goto m1;
			}
			if (pHumanPlayer->vCurrentChain->vMandatoryTrain == FALSE)
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			goto m1;
		}
		if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_UPGRADE)
		switch(pHumanPlayer->vStage)
		{
		case 300:
			if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vIdForComments == pHumanPlayer->vCurrentChain->vCommentUnit &&
				(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vIdTrain == pHumanPlayer->vCurrentChain->vId ||
				pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vId == pHumanPlayer->vCurrentChain->vId))
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			/*if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vIdForComments == pHumanPlayer->vCurrentChain->vCommentUnit &&
				pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->Postroeno == FALSE &&
				fCompliteBuild(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit,pHumanPlayer->vParamPlayer.vTimerGetElapsed) == TRUE)
			{
				//
			}*/
			if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vIdForComments == pHumanPlayer->vCurrentChain->vCommentUnit)
			{
				pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->fGetPostroeno();
				if (pHumanPlayer->vBase.vSlayerBaze == TRUE &&
					pHumanPlayer->vCurrentChain->vId == ID_UNIT_BUILD_WALL_VIOLET &&
					pHumanPlayer->vParamPlayer.vTimerGetElapsed < 2.5 * 60)
				{
					goto m1;
				}
				if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->Postroeno == TRUE &&
					pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->Upgrade == FALSE)
				{
					pHumanPlayer->vResult = fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit,pHumanPlayer->vCurrentChain->vId,1);
					if (pHumanPlayer->vResult == 1)
					{
						pHumanPlayer->vCurrentChain->vComplite = TRUE;
						pHumanPlayer->vParamPlayer.vStage++;
					}
					else if (pHumanPlayer->vResult != 0)
					{
						if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vIdForComments == pHumanPlayer->vCurrentChain->vCommentUnit)
						{
							fDelDataUnit(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vIdDataUnit);
						}
						if (pHumanPlayer->vForerunnerChainTemp &&
							((pHumanPlayer->vBase.vSlayerBaze == FALSE && pHumanPlayer->vForerunnerChainTemp->vN == 29) ||
							(pHumanPlayer->vBase.vSlayerBaze == TRUE && pHumanPlayer->vForerunnerChainTemp->vN == 32)))
						{
							sprintf(vBuf,"%s\0","Строим кориченвый вал");
							if (fNewChainActionBuild(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),COMMENT_MAIN_WALL,ID_UNIT_BUILD_WALL_BROWN,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
						}
						else
						{
							pHumanPlayer->vCurrentChain = pHumanPlayer->vForerunnerChainTemp;
							pHumanPlayer->vMassChains[pHumanPlayer->vCurrentChain->vN] = FALSE;
							goto m1;
						}
					}
				}
			}
			/*else
			{
				if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vIdForComments == pHumanPlayer->vCurrentChain->vCommentUnit &&
					pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->Postroeno == TRUE &&
					pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->Upgrade == TRUE)
				{
					fCancel_1(pHumanPlayer,pHumanPlayer->vCurrentChain->vCommentUnit);
				}
			}*/
			goto m1;
		}
		if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_RESEARCH)
		switch(pHumanPlayer->vStage)
		{
		case 300:
			if (pHumanPlayer->vParamPlayer.vResearch[pHumanPlayer->vCurrentChain->vNResearch] == TRUE)
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vIdForComments == pHumanPlayer->vCurrentChain->vCommentUnit &&
				pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->Researching == FALSE)
			{
				if (fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit,
					                     pHumanPlayer->vCurrentChain->vNResearch) == 1)
				{
					pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->Researching = TRUE;
					pHumanPlayer->vCurrentChain->vComplite = TRUE;
					pHumanPlayer->vParamPlayer.vStage++;
				}
			}
			goto m1;
		}
		if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_TO_WAIT_RESEARCH)
		switch(pHumanPlayer->vStage)
		{
		case 300:
			if (pHumanPlayer->vParamPlayer.vResearch[pHumanPlayer->vCurrentChain->vNResearch] == TRUE)
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			goto m1;
		}
		if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_SET_FLAG_TO_NEREST_TREE)
		switch(pHumanPlayer->vStage)
		{
		case 300:
			fSetFlagUnit(&pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit],&pHumanPlayer->vParamPlayer);
			pHumanPlayer->vCurrentChain->vComplite = TRUE;
			goto m1;
		}
		if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_NO)
		{
			pHumanPlayer->vCurrentChain->vComplite = TRUE;
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		}
		if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_IMBA_1)
		switch(pHumanPlayer->vStage)
		{
		case 300:
			pHumanPlayer->vFlagImba = FALSE;
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL)
			{
				if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_BLUE)
				{
					pHumanPlayer->vCurrentChain->vComplite = TRUE;
					pHumanPlayer->vParamPlayer.vStage = 399;
					goto m1;
				}
			}
			else
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage = 399;
				goto m1;
			}
			// Начинаем грейд синего вала
			if (fCheckRes(pHumanPlayer,0,5000) == TRUE)
			if (fTrainAction(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit,ID_UNIT_BUILD_WALL_BLUE,1) == 1)
			{
				pHumanPlayer->vFlagImba = TRUE;
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 301:
			// Начинаем грейды красных пушек в не зоны доступа рикошета или вблизи если нет вариантов
			pHumanPlayer->vQ = (unsigned short)pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_FIRE_LVL1);
			if (pHumanPlayer->vQ >= 4)
			{
				//pHumanPlayer->vActionStackForUnits.fSetCommentAll(COMMENT_NEW_UNIT,ID_UNIT_BUILD_TOWER_FIRE_LVL1,COMMENT_BUSY_UNIT);
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (fCheckRes(pHumanPlayer,0,4000) == TRUE)
			{
				if (fUpgradeUnit(pHumanPlayer,ID_UNIT_BUILD_TOWER_KONUS,ID_UNIT_BUILD_TOWER_FIRE_LVL1,TRUE,&pHumanPlayer->vActionStackForUnits) == FALSE)
				{
					if (pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_FIRE_LVL1) +
						pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_KONUS) < 4)
					{
						fUpgradeUnit(pHumanPlayer,ID_UNIT_BUILD_TOWER_GOLD,ID_UNIT_BUILD_TOWER_KONUS,TRUE,&pHumanPlayer->vActionStackForUnits);
					}
				}
			}
			else
			{
				/*if (pHumanPlayer->vQ >= 3)
				{
					pHumanPlayer->vParamPlayer.vStage += 2;
					goto m1;
				}
				if (pHumanPlayer->vQ >= 2)
				{
					pHumanPlayer->vParamPlayer.vStage += 3;
					goto m1;
				}
				if (pHumanPlayer->vQ >= 1)
				{
					pHumanPlayer->vParamPlayer.vStage += 4;
					goto m1;
				}*/
			}
			goto m1;
		case 302:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRE_1].vIdForComments == COMMENT_FIRE_1 &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRE_2].vIdForComments == COMMENT_FIRE_2 &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRE_3].vIdForComments == COMMENT_FIRE_3 &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRE_4].vIdForComments == COMMENT_FIRE_4)
			{
				pHumanPlayer->vActionStackForUnits.fSetCommentAll(COMMENT_NEW_UNIT,ID_UNIT_BUILD_TOWER_FIRE_LVL1,COMMENT_BUSY_UNIT);
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_BUSY_UNIT,ID_UNIT_BUILD_TOWER_FIRE_LVL1,COMMENT_FIRE_1) == true &&
				pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_BUSY_UNIT,ID_UNIT_BUILD_TOWER_FIRE_LVL1,COMMENT_FIRE_2) == true &&
				pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_BUSY_UNIT,ID_UNIT_BUILD_TOWER_FIRE_LVL1,COMMENT_FIRE_3) == true &&
				pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_BUSY_UNIT,ID_UNIT_BUILD_TOWER_FIRE_LVL1,COMMENT_FIRE_4) == true)
			{
				//pHumanPlayer->vActionStackForUnits.fSetCommentAll(COMMENT_NEW_UNIT,ID_UNIT_BUILD_TOWER_FIRE_LVL1,COMMENT_BUSY_UNIT);
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			pHumanPlayer->vParamPlayer.vStage = 301;
			goto m1;
		case 303:
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 304:
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 305:
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 306:
			/*if (fAllWood(pHumanPlayer) >= 65000)
			{
				pHumanPlayer->vFlagImba = FALSE;
			}*/
			if (pHumanPlayer->vFlagImba == TRUE &&
				((pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeAttackWall > 10) ||
				pHumanPlayer->vTimeAttackWall == 0) &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRE_1].vIdForComments == COMMENT_FIRE_1 &&
				((pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRE_1].pDataUnit->vTimeEndTrain - 3) < pHumanPlayer->vParamPlayer.vTimerGetElapsed))
			{
				if ((pDataHumans->vBaseHelp1 &&
					pDataHumans->vBaseHelp1 == &pHumanPlayer->vBase) ||
					(pDataHumans->vBaseHelp2 &&
					pDataHumans->vBaseHelp2 == &pHumanPlayer->vBase))
				{
					pHumanPlayer->vCurrentChain->vComplite = TRUE;
					pHumanPlayer->vParamPlayer.vStage++;
					goto m1;
				}
				// Отменяем строительство синего вала и 4 красных пушек
				if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL)
				{
					fAddDataUnitInRange(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit);
				}
				fCancel_1(pHumanPlayer,COMMENT_MAIN_WALL);
				fCancel_1(pHumanPlayer,COMMENT_FIRE_1);
				fCancel_1(pHumanPlayer,COMMENT_FIRE_2);
				fCancel_1(pHumanPlayer,COMMENT_FIRE_3);
				fCancel_1(pHumanPlayer,COMMENT_FIRE_4);
				pHumanPlayer->vTimeImba = FALSE;
				if (fAllWood(pHumanPlayer) >= 20000 &&
					GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 1 &&
					fGetAllWood(pHumanPlayer) == TRUE)
				{
					pHumanPlayer->vCurrentChain->vComplite = TRUE;
					pHumanPlayer->vParamPlayer.vStage++;
					goto m1;
				}
				else
				{
					pHumanPlayer->vParamPlayer.vStage = 300;
				}
			}
			if (pHumanPlayer->vFlagImba == FALSE)
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		}
		if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_UP_MANA)
		switch(pHumanPlayer->vStage)
		{
		case 300:
			pHumanPlayer->vInt3 = pHumanPlayer->vBase.vRepairPos[3].vInt3;
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->Permission = FALSE;
			if (pHumanPlayer->vInt3 != vSizeMap)
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vId);
				pHumanPlayer->vParamPlayer.vStage++;
			}
			else
			{
				pHumanPlayer->vCurrentChain->vComplite = TRUE;
				pHumanPlayer->vParamPlayer.vStage = 399;
				goto m1;
			}
			goto m1;
		case 301:
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vId,pHumanPlayer->vInt3,ACTION_GO) == 1)
			{
				pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vTimeGoTo = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
				pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 302:
			if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vActionFinish == 1)
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vTimeGoTo > 10)
			{
				pHumanPlayer->vParamPlayer.vStage = 300;
				goto m1;
			}
			goto m1;
		case 303:
			pHumanPlayer->vMana = GetUnitState(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->WhichUnit, UNIT_STATE_MANA);
			if (((unsigned int)pHumanPlayer->vMana < 10 && fIsMainHuman(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vId)) ||
				((unsigned int)pHumanPlayer->vMana < 3 && pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].pDataUnit->vId == ID_UNIT_URSA))
			{
				goto m1;
			}
			pHumanPlayer->vBlockRepair = FALSE;
			pHumanPlayer->vCurrentChain->vComplite = TRUE;
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		}
	}

	if (pHumanPlayer->vCurrentEra == 0)
	if (pHumanPlayer->vCurrentChain && pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_UNIVERSAL)
	if (pHumanPlayer->vStage >= 201 && pHumanPlayer->vStage <= 299)
	{
		switch (pHumanPlayer->vStage)
		{
		case 201:
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_GEM2] == TRUE)
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_GEM1] == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				if (fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_GEM2) == 1)
					pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 202:
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_GEM3] == TRUE)
			{
				pHumanPlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pHumanPlayer->vParamPlayer.vResearch[N_RESEARCH_GEM2] == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].vIdForComments == COMMENT_FIRST_KUZNYA &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit->Researching == FALSE)
			{
				if (fTrainActionResearch(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_KUZNYA].pDataUnit,N_RESEARCH_GEM3) == 1)
					pHumanPlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 203:
			// Если тип базы не слаерка в начале
			if (pHumanPlayer->vBase.vSlayerBaze == FALSE)
			{
				pHumanPlayer->vParamPlayer.vStage = 71;
			}
			else
			{
				pHumanPlayer->vBase.vSlayerBaze = FALSE;
				pHumanPlayer->vParamPlayer.vStage = 71;
			}
			goto m1;
		case 204:
			//pHumanPlayer->vCurrentEra = pHumanPlayer->vNextEra;
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 205:
			pHumanPlayer->vBase.vWallCreated = TRUE;
			fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
			pHumanPlayer->vInt3 = pHumanPlayer->vBase.vRepairPos[3].vInt3;
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->Permission = FALSE;
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_GO) == 1);
			pHumanPlayer->vParamPlayer.vStage++;
			goto m1;
		case 207:
			if (pHumanPlayer->vActionStackForUnits.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_KONUS) >= 4)
			{
				pHumanPlayer->vParamPlayer.vStage++;
			}
			else
			{
				// Грейдим 4 конуса в не зоны доступа
				if (fUpgradeUnit(pHumanPlayer,ID_UNIT_BUILD_TOWER_GOLD,ID_UNIT_BUILD_TOWER_KONUS,FALSE,&pHumanPlayer->vActionStackForUnits) == FALSE)
				{
					sprintf(vBuf,"%s\0","Строим пушки для 4 конусов!");
					if (fNewChainActionUniversal(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),80,vBuf) == TRUE);
				}
			}
			goto m1;
		case 209:
			for (pHumanPlayer->vvi = 1; pHumanPlayer->vvi <= 5; pHumanPlayer->vvi++)
			{
				if (pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi].vIdForComments == pHumanPlayer->vvi &&
					pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi+1].vIdForComments == (pHumanPlayer->vvi+1) &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].vIdForComments != COMMENT_TOWER_HOUSE)
				{
					if (fG(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi].pDataUnit->LastCoordinates.X,
						   pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi].pDataUnit->LastCoordinates.Y,
						   pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi+1].pDataUnit->LastCoordinates.X,
						   pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi+1].pDataUnit->LastCoordinates.Y) <= (128 *2) &&
						   fMiddleRect(&pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi].pDataUnit->vRect1,
									&pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vvi+1].pDataUnit->vRect1,
									&pHumanPlayer->vRect7) == TRUE)
					{
						pHumanPlayer->vRect7.vX2 = pHumanPlayer->vRect7.vX1 + 4 - 1;
						pHumanPlayer->vRect7.vY2 = pHumanPlayer->vRect7.vY1 + 4 - 1;
						pHumanPlayer->vInt3 = fConvertXYToI(pHumanPlayer->vRect7.vX1,pHumanPlayer->vRect7.vY1);
						if (pHumanPlayer->vInt3 != vSizeMap && fCheckMapUnitsRect(&pHumanPlayer->vRect7,HUMANS) == TRUE)
						{
							if (fDelChainByN(pHumanPlayer,pHumanPlayer->vCurrentChain->vN) == TRUE)
							{
								pHumanPlayer->vBlockRepair = TRUE;
								sprintf(vBuf,"%s\0","Блинкнуться в безопасную зону");
								if (fNewChainActionUniversal(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),73,vBuf) == TRUE);
								sprintf(vBuf,"%s\0","Найти безопасную зону на базе");
								if (fNewChainActionUniversal(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),72,vBuf) == TRUE);
								sprintf(vBuf,"%s\0","Строим пушку!");
								if (fNewChainActionBuild(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),COMMENT_TOWER_HOUSE,ID_UNIT_BUILD_TOWER_WHITE,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
								fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[pHumanPlayer->vCurrentChain->vCommentUnit].vId);
								pHumanPlayer->vParamPlayer.vStage = 301;
								goto m1;
							}
						}
					}
				}
			}
			goto m1;
		case 210:
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].vIdForComments == COMMENT_TOWER_HOUSE)
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->Postroeno == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->vId == ID_UNIT_BUILD_TOWER_GOLD)
			{
				// Грейдим пушку в конус
				if (//pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->Upgrade == FALSE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->vIdTrain != ID_UNIT_BUILD_TOWER_KONUS &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->vId != ID_UNIT_BUILD_TOWER_KONUS)
				{
					sprintf(vBuf,"%s\0","Улучшаем пушку в конус!");
					if (fNewChainActionUpgrade(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),ID_UNIT_BUILD_TOWER_KONUS,COMMENT_TOWER_HOUSE,vBuf) == TRUE);
				}
				/*if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->Upgrade == FALSE)
				if (fUpgradeUnit(pHumanPlayer,ID_UNIT_BUILD_TOWER_GOLD,ID_UNIT_BUILD_TOWER_KONUS,FALSE,&pHumanPlayer->vActionStackForUnitsTower) == FALSE)
				{
					sprintf(vBuf,"%s\0","Не удалось апгрейдить!");
				}*/
				if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->Postroeno == TRUE &&
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->vId == ID_UNIT_BUILD_TOWER_KONUS)
				{
					pHumanPlayer->vParamPlayer.vStage++;
				}
			}
			else
			{
				// Грейдим пушку в золотую
				/*if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->Upgrade == FALSE)
				if (fUpgradeUnit(pHumanPlayer,ID_UNIT_BUILD_TOWER_WHITE,ID_UNIT_BUILD_TOWER_GOLD,FALSE,&pHumanPlayer->vActionStackForUnitsTower) == FALSE)
				{
					sprintf(vBuf,"%s\0","Не удалось апгрейдить!");
				}*/
				if (//pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->Upgrade == FALSE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->vIdTrain != ID_UNIT_BUILD_TOWER_GOLD &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_HOUSE].pDataUnit->vId != ID_UNIT_BUILD_TOWER_KONUS)
				{
					sprintf(vBuf,"%s\0","Улучшаем пушку в золотую!");
					if (fNewChainActionUpgrade(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),ID_UNIT_BUILD_TOWER_GOLD,COMMENT_TOWER_HOUSE,vBuf) == TRUE);
				}
			}
			goto m1;
		}
	}
m1:;
	//pHumanPlayer->vParamPlayer.vBusy = FALSE;
}

// Комментируем по новой
bool fWeCommentOnTheNew(HumanPlayer *pHumanPlayer, ActionStackForUnits *pActionStackForUnits)
{
	if (pHumanPlayer == NULL || pActionStackForUnits == NULL) return FALSE;
	
	if (pHumanPlayer->vParamPlayer.vStage >= 6)
	{
		for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi <= 17; pHumanPlayer->vvi++)
		{
			if (pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[(unsigned short)pHumanPlayer->vvi].vIdForComments == COMMENT_NEW_UNIT &&
				pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[(unsigned short)pHumanPlayer->vvi].vIdForComments != (unsigned short)pHumanPlayer->vvi &&
				fGetId((unsigned short)pHumanPlayer->vvi,pHumanPlayer->vParamPlayer.vStage,&pHumanPlayer->vId) == TRUE &&
				pActionStackForUnits->fSetComment(COMMENT_NEW_UNIT,pHumanPlayer->vId,(unsigned short)pHumanPlayer->vvi) == true);
		}
		
	}
	return TRUE;
}

// Строим по новой
bool fBuildANewOne(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	return TRUE;
}

// Детонируем юнитов
bool fDeto(HumanPlayer *pHumanPlayer, integer vId, unsigned short vQ, ActionStackForUnits *pActionStackForUnits)
{
	if (pHumanPlayer == NULL || pActionStackForUnits == NULL) return FALSE;
		StackForUnits *current = pActionStackForUnits->first;
		pHumanPlayer->vQ = 0;
		while (current && (unsigned int)current != 0xdddddddd)
		{
			if (1)
			{
				if (current->vIdDataUnit2.pDataUnit)
				{
					if (current->vIdDataUnit2.pDataUnit->vId == vId)
					{
						if (IssuePointOrderById(current->vIdDataUnit2.pDataUnit->WhichUnit,
												ID_ORDER_DETONATE,
												current->vIdDataUnit2.pDataUnit->LastCoordinates.X,
												current->vIdDataUnit2.pDataUnit->LastCoordinates.Y) == TRUE)
						{
							pHumanPlayer->vQ++;
						}
						if (pHumanPlayer->vQ == vQ)
						{
							return TRUE;
						}
						if (pHumanPlayer->vQ > 6) return TRUE;
					}
				}
			}
			current = current->next;
		}
	return FALSE;
}

// Проверить ресурсы
bool fCheckRes(HumanPlayer *pHumanPlayer, integer vGold, integer vWood)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= vGold &&
		GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER) >= vWood)
	{
		return TRUE;
	}
	return FALSE;
}

// Проверить простроены ли храм и лесопилка
bool fCheckTempleAndLumberHouse(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vBase.vTempleAndLumberHouse == TRUE) return TRUE;
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TEMPLE].vIdForComments == COMMENT_TEMPLE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].vIdForComments == COMMENT_FIRST_DOM &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_FIRST_DOM].pDataUnit->vId == ID_UNIT_BUILD_LESOPILKA1)
	{
		pHumanPlayer->vBase.vTempleAndLumberHouse = TRUE;
		pHumanPlayer->vBase.vTwoGold = FALSE;
		return TRUE;
	}
	return FALSE;
}

// Проверить 2 эру у всех хуманов
bool fCheckEra2All(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pDataHumans->vEra1All == TRUE) return TRUE;
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
	{
		if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTempleAndLumberHouse == FALSE)
		{
			return FALSE;
		}
	}
	pDataHumans->vEra1All = TRUE;
	return TRUE;
}

// Отдать золото
bool fGiveAwayGold(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vBase.vTempleAndLumberHouse == FALSE || pDataHumans->vEra1All == TRUE) return FALSE;
	pHumanPlayer->vAllGold = GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD);
	if (pHumanPlayer->vAllGold < 10) return FALSE;
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
	{
		if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTempleAndLumberHouse == FALSE &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTwoGold == FALSE)
		{
			if (fTransferRes(pHumanPlayer->vParamPlayer.vPlayer,
							 pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
							 PLAYER_STATE_RESOURCE_LUMBER,
							 GetPlayerState(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER)) == FALSE);
			if (fTransferRes(pHumanPlayer->vParamPlayer.vPlayer,
							 pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
							 PLAYER_STATE_RESOURCE_GOLD,
							 10) == FALSE);
			pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTwoGold = TRUE;
			return TRUE;
		}
	}
	return FALSE;
}

// Продать золото
bool fSaleGold(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vBase.vTempleAndLumberHouse == FALSE || pDataHumans->vEra1All == TRUE) return FALSE;
	pHumanPlayer->vAllGold = GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD);
	if (pHumanPlayer->vAllGold < 2) return FALSE;
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
	{
		if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTempleAndLumberHouse == FALSE &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTwoGold == FALSE)
		{
			pHumanPlayer->vAllWood = GetPlayerState(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER);
			if (pHumanPlayer->vAllWood >= 8000)
			{
				if (fTransferRes(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
								 pHumanPlayer->vParamPlayer.vPlayer,
								 PLAYER_STATE_RESOURCE_LUMBER,
								 8000) == FALSE);
				if (fTransferRes(pHumanPlayer->vParamPlayer.vPlayer,
								 pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
								 PLAYER_STATE_RESOURCE_GOLD,
								 2) == FALSE);
				pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTwoGold = TRUE;
				return TRUE;
			}
		}
	}
	return FALSE;
}

// Взять 2 золота
bool fGetAllGoldLimit2(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	pHumanPlayer->vQ = 0;
	// Пробегаем по всем хуманам
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
	{
		// Если хуман мейн есть и другой игрок
		if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer)
		{
			// Берём его золото
			pHumanPlayer->vAllGold = GetPlayerState(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD);
			// Если золота нет то дальше
			if (pHumanPlayer->vAllGold == 0) continue;
			// Если два голда есть и золота больше 2
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTwoGold == TRUE &&
				pHumanPlayer->vAllGold > 2)
			{
				// Берём максиммум два
				pHumanPlayer->vAllGold -= 2;
				if (pHumanPlayer->vAllGold > 2)
				{
					pHumanPlayer->vAllGold = 2;
				}
				goto m1;
			}
			// Если нет два голда, но золото есть
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTwoGold == FALSE &&
				pHumanPlayer->vAllGold > 0)
			{
				goto m1;
			}
			continue;
m1:
			pHumanPlayer->vQ += pHumanPlayer->vAllGold;
			if (fTransferRes(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
								pHumanPlayer->vParamPlayer.vPlayer,
								PLAYER_STATE_RESOURCE_GOLD,
								pHumanPlayer->vAllGold) == FALSE);
			if (pHumanPlayer->vQ >= 2) return TRUE;// Взяли два года
		}
	}
	return FALSE;
}

// Подсчетать всё золото
integer fAllGold(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	pHumanPlayer->vAllGold = 0;
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
	{
		if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN)
		{
			pHumanPlayer->vAllGold += GetPlayerState(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD);
		}
	}
	return pHumanPlayer->vAllGold;
}

// Взять всё дерево
bool fGetAllWood(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
	{
		if (//pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBase != DO_NOT_FIND_BASE &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTempleAndLumberHouse == FALSE)
		{
			if (fTransferRes(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
								pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER,
								GetPlayerState(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER)) == FALSE);
		}
	}
	return TRUE;
}

// Подсчетать всё дерево
integer fAllWood(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	pHumanPlayer->vAllWood = 0;
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
	{
		if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
			pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vTempleAndLumberHouse == FALSE)
		{
			pHumanPlayer->vAllWood += GetPlayerState(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER);
		}
	}
	return pHumanPlayer->vAllWood;
}

// Улучшить юнита в стаке
bool fUpgradeUnit(HumanPlayer *pHumanPlayer, integer vId, integer vId2, bool vFlagRicochet, ActionStackForUnits *pActionStackForUnits)
{
	if (pHumanPlayer == NULL || pActionStackForUnits == NULL) return FALSE;
		//pHumanPlayer->vActionStackForUnits.fGetIdDataUnit(COMMENT_BUSY_UNIT,ID_UNIT_BUILD_TOWER_GOLD)->pDataUnit;
	StackForUnits *current;
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < 2; pHumanPlayer->vvi++)
	{
		pHumanPlayer->vFlag3 = FALSE;
		if (pHumanPlayer->vvi == 0)
		{
			pHumanPlayer->vFlagRicochet = vFlagRicochet;
		}
		if (pHumanPlayer->vvi == 1)
		{
			if (pHumanPlayer->vFlagRicochet == FALSE)
			{
				pHumanPlayer->vFlagRicochet = TRUE;
			}
			else
			{
				pHumanPlayer->vFlagRicochet = FALSE;
			}
		}
		if (pHumanPlayer->vFlagRicochet == FALSE)
		{
			pHumanPlayer->vFlag3 = TRUE;
		}
		else
		{
			pHumanPlayer->vMax = 0;
			pHumanPlayer->vUnitRadiusMax = NULL;
		}
		current = pActionStackForUnits->first;
		while (current && (unsigned int)current != 0xdddddddd)
		{
			if (1)
			{
				if (current->vIdDataUnit2.pDataUnit)
				{
					if (pHumanPlayer->vFlag3 == FALSE)
					if (current->vIdDataUnit2.pDataUnit->vId == vId &&
						current->vIdDataUnit2.pDataUnit->vIdTrain != vId2 &&
						pHumanPlayer->vBase.vMainWall)
					{
						pHumanPlayer->vG = fG(current->vIdDataUnit2.pDataUnit->LastCoordinates.X,
											  current->vIdDataUnit2.pDataUnit->LastCoordinates.Y,
											  fConvertIToRX(pHumanPlayer->vBase.vMainWall->vInt3),
											  fConvertIToRY(pHumanPlayer->vBase.vMainWall->vInt3));
						if (pHumanPlayer->vMax == 0 ||
							(pHumanPlayer->vG > pHumanPlayer->vMax))
						{
							pHumanPlayer->vMax = pHumanPlayer->vG;
							pHumanPlayer->vUnitRadiusMax = current;
						}
					}
					if (pHumanPlayer->vFlag3 == TRUE)
					if (current->vIdDataUnit2.pDataUnit->vId == vId &&
						current->vIdDataUnit2.pDataUnit->vIdTrain != vId2 &&
						current->vIdDataUnit2.pDataUnit->vHead->vRicochet == pHumanPlayer->vFlagRicochet)
					{
						current->vIdDataUnit2.pDataUnit->fGetPostroeno();
						if (fTrainAction(pHumanPlayer,
										 current->vIdDataUnit2.pDataUnit,
										 vId2,
										 1) == 1)
						{
							fGetTimeCompliteTrain(vId2,&current->vIdDataUnit2.pDataUnit->vTimeCompliteTrain);
							current->vIdDataUnit2.pDataUnit->vTimeStartTrain = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
							current->vIdDataUnit2.pDataUnit->vTimeEndTrain = current->vIdDataUnit2.pDataUnit->vTimeStartTrain +
																			 current->vIdDataUnit2.pDataUnit->vTimeCompliteTrain;
							return TRUE;
						}
					}
				}
			}
			current = current->next;
		}
		if (pHumanPlayer->vFlag3 == FALSE &&
			pHumanPlayer->vUnitRadiusMax)
		{
			if (pHumanPlayer->vUnitRadiusMax->vIdDataUnit2.pDataUnit->vId == vId)
			{
				pHumanPlayer->vUnitRadiusMax->vIdDataUnit2.pDataUnit->fGetPostroeno();
				if (fTrainAction(pHumanPlayer,
								 pHumanPlayer->vUnitRadiusMax->vIdDataUnit2.pDataUnit,
								 vId2,
								 1) == 1)
				{
					fGetTimeCompliteTrain(vId2,&pHumanPlayer->vUnitRadiusMax->vIdDataUnit2.pDataUnit->vTimeCompliteTrain);
					pHumanPlayer->vUnitRadiusMax->vIdDataUnit2.pDataUnit->vTimeStartTrain = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
					pHumanPlayer->vUnitRadiusMax->vIdDataUnit2.pDataUnit->vTimeEndTrain = pHumanPlayer->vUnitRadiusMax->vIdDataUnit2.pDataUnit->vTimeStartTrain +
																		                  pHumanPlayer->vUnitRadiusMax->vIdDataUnit2.pDataUnit->vTimeCompliteTrain;
					return TRUE;
				}
			}
		}
	}
	return FALSE;
}

// Жгём ману юниту
bool fManaBurnToUnit(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, DataUnit *pDataUnitTarget)
{
	if (pHumanPlayer == NULL || pDataUnit == NULL || pDataUnitTarget == NULL) return FALSE;
	if (pDataUnit->vPosRepair > 0 && GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA) < 1)
	{
			pHumanPlayer->vX_1 = pDataUnit->LastCoordinates.X;
			pHumanPlayer->vY_1 = pDataUnit->LastCoordinates.Y;
			pHumanPlayer->vX_2 = fGetMinIX2RX(fConvertIToX(pDataUnit->vPosRepair))+32;
			pHumanPlayer->vY_2 = fGetMinIY2RY(fConvertIToY(pDataUnit->vPosRepair))-32;
			pHumanPlayer->vG = fG(pHumanPlayer->vX_1,
								  pHumanPlayer->vY_1,
								  pHumanPlayer->vX_2,
								  pHumanPlayer->vY_2);
			if (pHumanPlayer->vG > 16)
			{
				pHumanPlayer->vMainHuman.vManaBurn.vCast = FALSE;
			}
	}
	if (pDataUnit->vActionFinish == 0 &&
		pHumanPlayer->vMainHuman.vManaBurn.vCast == TRUE) return TRUE;
	pHumanPlayer->vMainHuman.vManaBurn.vCast = FALSE;
	if (pHumanPlayer->vMainHuman.vManaBurn.vTimeEndCoolDown < pHumanPlayer->vParamPlayer.vTimerGetElapsed ||
		pHumanPlayer->vMainHuman.vManaBurn.vTimeEndCoolDown == 0)
	{
		pHumanPlayer->vMainHuman.vManaBurn.Available = TRUE;
		if (GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA) >= pHumanPlayer->vMainHuman.vManaBurn.vMana)
		if (fG(pDataUnit->LastCoordinates.X,pDataUnit->LastCoordinates.Y,pDataUnitTarget->LastCoordinates.X,pDataUnitTarget->LastCoordinates.Y) <
			pHumanPlayer->vMainHuman.vManaBurn.vRadius)
		if (IssueTargetOrderById(pDataUnit->WhichUnit,
								pHumanPlayer->vMainHuman.vManaBurn.vId,
								pDataUnitTarget->WhichUnit) == TRUE)
		{
			// Делаем манабёрн
			pHumanPlayer->vMainHuman.vManaBurn.vTimeEndCoolDown = pHumanPlayer->vParamPlayer.vTimerGetElapsed + pHumanPlayer->vMainHuman.vManaBurn.CoolDown;
			pHumanPlayer->vMainHuman.vManaBurn.Available = FALSE;
			pHumanPlayer->vMainHuman.vManaBurn.vCast = TRUE;
			fFreeActionUnit(pDataUnit->vIdDataUnit);
			pDataUnit->Permission = TRUE;
			pDataUnit->PermissionMove = TRUE;
			return TRUE;
		}
	}
	return FALSE;
}

// Иницализация спелов юнитов у человека
bool fInitSpellsUnitsByHuman(HumanPlayer *pHumanPlayer)
{
	pHumanPlayer->vMainHuman.vManaBurn.vCast = FALSE;
	pHumanPlayer->vMainHuman.vManaBurn.vId = ID_ORDER_MANABURN;
	pHumanPlayer->vMainHuman.vManaBurn.lvl = 1;
	pHumanPlayer->vMainHuman.vManaBurn.vTimeEndCoolDown = 0;
	fGetCoolDamage(pHumanPlayer->vMainHuman.vManaBurn.vId,pHumanPlayer->vMainHuman.vManaBurn.lvl,&pHumanPlayer->vMainHuman.vManaBurn.Damage);
	fGetCoolDown(pHumanPlayer->vMainHuman.vManaBurn.vId,pHumanPlayer->vMainHuman.vManaBurn.lvl,&pHumanPlayer->vMainHuman.vManaBurn.CoolDown);
	fGetCoolRadius(pHumanPlayer->vMainHuman.vManaBurn.vId,pHumanPlayer->vMainHuman.vManaBurn.lvl,&pHumanPlayer->vMainHuman.vManaBurn.vRadius);
	fGetManaSpell(pHumanPlayer->vMainHuman.vManaBurn.vId,pHumanPlayer->vMainHuman.vManaBurn.lvl,&pHumanPlayer->vMainHuman.vManaBurn.vMana);
	return TRUE;
}

// Прийти на помощь
bool fComeToTheRescue(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	pHumanPlayer->pDataUnit2 = NULL;
	pHumanPlayer->vFlagRepair = FALSE;
		// Управление ремонтом урс
		pHumanPlayer->current = pHumanPlayer->vActionStackForUnitsFurbolgs.first;
		while (pHumanPlayer->current && (unsigned int)pHumanPlayer->current != 0xdddddddd)
		{
			if (pHumanPlayer->current->vIdDataUnit2.pDataUnit->vHelping == TRUE)
			if (fRepairUnitByUnit(pHumanPlayer,
							      pHumanPlayer->current->vIdDataUnit2.pDataUnit,
							      pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit) == TRUE);
			pHumanPlayer->current = pHumanPlayer->current->next;
		}
	if (pHumanPlayer->vBlockRepair == FALSE)
	if (pHumanPlayer->pDataUnit2 == NULL &&
		pDataHumans->vBaseHelp1 &&
		pHumanPlayer->vParamPlayer.vAI >= 0 &&
		pHumanPlayer->vParamPlayer.vAI <= 5)
	{
		pHumanPlayer->vHelpBase = pDataHumans->vBaseHelp1;
		if (pHumanPlayer->vHelpBase->pHumanPlayer)
		{
			pHumanPlayer->pDataUnit2 = pHumanPlayer->vHelpBase->pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit;
		}
		else
		{
			pHumanPlayer->pDataUnit2 = pHumanPlayer->pDataUnit2;
		}
	}
	if (pHumanPlayer->vBlockRepair == FALSE)
	if (pHumanPlayer->pDataUnit2 == NULL &&
		pDataHumans->vBaseHelp2 &&
		pHumanPlayer->vParamPlayer.vAI >= 6 &&
		pHumanPlayer->vParamPlayer.vAI <= 9)
	{
		pHumanPlayer->vHelpBase = pDataHumans->vBaseHelp2;
		if (pHumanPlayer->vHelpBase->pHumanPlayer)
		{
			pHumanPlayer->pDataUnit2 = pHumanPlayer->vHelpBase->pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit;
		}
		else
		{
			pHumanPlayer->pDataUnit2 = pHumanPlayer->pDataUnit2;
		}
	}
	/*if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
		pHumanPlayer->vBlockRepair == TRUE)
	{
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vPosRepair > 0)
		{
			//vMapBases.fFreePosRepair(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelpBase,
			//						 pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vPosRepair);
			vMapBases.fFreePosRepairBind(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelpBase,
									 pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vPosRepair);
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vPosRepair = 0;
		}
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelping = FALSE;
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelpBase = NULL;
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vStageHelp = 0;
	}*/
	// Управление ремонтом мейна
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vFlagBuild == FALSE &&
		//pHumanPlayer->vBlockRepair == FALSE &&
		((pHumanPlayer->vBase.vTempleAndLumberHouse == FALSE &&
		pHumanPlayer->vCurrentChain &&
		((pHumanPlayer->vCurrentChain->vN >= 30 &&
		pHumanPlayer->vCurrentChain->vN < pHumanPlayer->MAX_Q_FOR_MASS_CHAINS - 500 &&
		(pHumanPlayer->vParamPlayer.vTimerGetElapsed < 2.5 * 60) || pHumanPlayer->vHelpBase == pDataHumans->vBaseHelp1 || pHumanPlayer->vHelpBase == pDataHumans->vBaseHelp2) ||
		(pHumanPlayer->vCurrentChain->vN > 40 &&
		pHumanPlayer->vCurrentChain->vN < pHumanPlayer->MAX_Q_FOR_MASS_CHAINS - 500 &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed > 2.5 * 60))) ||
		(pHumanPlayer->vBase.vTempleAndLumberHouse == TRUE &&
		(pDataHumans->vBaseHelp1 == &pHumanPlayer->vBase ||
		pDataHumans->vBaseHelp2 == &pHumanPlayer->vBase) ||
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelping == TRUE)))
	{
		if (fRepairUnitByUnit(pHumanPlayer,
							  pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit,
							  pHumanPlayer->pDataUnit2) == TRUE)
		{
			pHumanPlayer->vFlagRepair = TRUE;
			if (pHumanPlayer->vBlockRepair == FALSE)
			{
				if (pHumanPlayer->vCurrentChain)
				{
					pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentChain->vStage;
					//pHumanPlayer->vBlockRepair = TRUE;
				}
			}
		}
		else
		{
			/*if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vPosRepair > 0)
			{
				//vMapBases.fFreePosRepair(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelpBase,
				//	                     pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vPosRepair);
				vMapBases.fFreePosRepairBind(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelpBase,
					                         pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vPosRepair);
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vPosRepair = 0;
			}*/
			pHumanPlayer->vFlagRepair = FALSE;
		}
	}
	else
	{
		if (pHumanPlayer->vFlagRepair == TRUE)
		{
			pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentChain->vStage;
			//pHumanPlayer->vBlockRepair = TRUE;
		}
		pHumanPlayer->vFlagRepair = FALSE;
	}
	if (pDataHumans->vBaseHelp1 == NULL &&
		pDataHumans->vBaseHelp2 == NULL)
	{
		return FALSE;
	}
	// Упрвляем началом управления урсами для ремонта
	if (pDataHumans->vBaseHelp1 == &pHumanPlayer->vBase ||
		pDataHumans->vBaseHelp2 == &pHumanPlayer->vBase)
	{
		pHumanPlayer->vQ = 0;
		pHumanPlayer->current = pHumanPlayer->vActionStackForUnitsFurbolgs.first;
		while (pHumanPlayer->current && (unsigned int)pHumanPlayer->current != 0xdddddddd)
		{
			pHumanPlayer->vMana = GetUnitState(pHumanPlayer->current->vIdDataUnit2.pDataUnit->WhichUnit, UNIT_STATE_MANA);
			if (((unsigned int)pHumanPlayer->vMana >= 3 &&
				pHumanPlayer->current->vIdDataUnit2.pDataUnit->vHelping == FALSE) ||
				pHumanPlayer->current->vIdDataUnit2.pDataUnit->vHelping == TRUE)
			if (fRepairUnitByUnit(pHumanPlayer,
							      pHumanPlayer->current->vIdDataUnit2.pDataUnit,
							      pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit) == TRUE)
			{
				pHumanPlayer->vQ++;
			}
			if (pHumanPlayer->vQ >= 5) break;
			pHumanPlayer->current = pHumanPlayer->current->next;
		}
	}
	return FALSE;
}

// Сигнал о помощи
void fASignalForHelp(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return;
	// Не родная база
	if (pHumanPlayer->vFlagDearBase == FALSE &&
		pDataHumans->vFlagHelp1 == TRUE &&
		&pHumanPlayer->vBase == pDataHumans->vBaseHelp1)
	{
		pDataHumans->vFlagHelp1 = FALSE;
		pDataHumans->vBaseHelp1 = NULL;
	}
	if (pHumanPlayer->vFlagDearBase == FALSE &&
		pDataHumans->vFlagHelp2 == TRUE &&
		&pHumanPlayer->vBase == pDataHumans->vBaseHelp2)
	{
		pDataHumans->vFlagHelp2 = FALSE;
		pDataHumans->vBaseHelp2 = NULL;
	}
	// Слаерам не помогаем
	if (pHumanPlayer->vBase.vSlayerBaze == TRUE)
	{
		if (pHumanPlayer->vParamPlayer.vTimerGetElapsed < 60 * 2.5)
		{
			return;
		}
		//else if (pHumanPlayer->vBlockRepair == FALSE)
		//{
		//	pHumanPlayer->vBlockRepair = TRUE;
		//}
	}
	// Мою базу атакуют 2 вампа
	/*if (pDataHumans->vBaseHelp1 &&
		pDataHumans->vBaseHelp2 &&
		&pHumanPlayer->vBase == pDataHumans->vBaseHelp1 &&
		&pHumanPlayer->vBase == pDataHumans->vBaseHelp2)
	{
		return;
	}*/
	// Вышло 12 минут
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_BROWN ||
		//pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_YELLOW ||
		(((pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_YELLOW &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vIdTrain == ID_UNIT_BUILD_WALL_VIOLET) ||
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET) &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed > 60 * 12)))
	{
		return;
	}
	pHumanPlayer->vCount = 0;
	pHumanPlayer->vNoVamp = FALSE;
	if (pHumanPlayer->vBase.vSlayerBaze == FALSE &&
		//pHumanPlayer->vFlagRepair == TRUE &&
		//pHumanPlayer->vCountTowerWhite >= 12 &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		((pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId != ID_UNIT_BUILD_WALL_BROWN &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId != ID_UNIT_BUILD_WALL_YELLOW &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId != ID_UNIT_BUILD_WALL_VIOLET) ||
		(pHumanPlayer->vParamPlayer.vTimerGetElapsed < 60*12 &&
		//pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Atakovan == FALSE &&
		((pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_YELLOW &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vIdTrain == ID_UNIT_BUILD_WALL_VIOLET &&
		(pHumanPlayer->vParamPlayer.vTimerGetElapsed > pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vTimeEndTrain - 10)) ||
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET))))
	{
		pHumanPlayer->vX_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->LastCoordinates.X;
		pHumanPlayer->vY_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->LastCoordinates.Y;
		for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < MAX_VAMPIRE_PLAYERS; pHumanPlayer->vvi++)
		{
			if (vDataUnits[10 + pHumanPlayer->vvi].pDataUnit)
			{
				if (IsUnitVisible(vDataUnits[10 + pHumanPlayer->vvi].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE)
				{
					pHumanPlayer->vX_2 = vDataUnits[10 + pHumanPlayer->vvi].pDataUnit->LastCoordinatesForEnemy.X;
					pHumanPlayer->vY_2 = vDataUnits[10 + pHumanPlayer->vvi].pDataUnit->LastCoordinatesForEnemy.Y;
					pHumanPlayer->vG = fG(pHumanPlayer->vX_1,pHumanPlayer->vY_1,pHumanPlayer->vX_2,pHumanPlayer->vY_2);
					if (pHumanPlayer->vG < 128 * 3)
					{
						if (pHumanPlayer->vvi == 0)
						{
							pDataHumans->vBaseHelp1Wall = &pHumanPlayer->vBase;
						}
						if (pHumanPlayer->vvi == 1)
						{
							pDataHumans->vBaseHelp2Wall = &pHumanPlayer->vBase;
						}
					}
					if (pHumanPlayer->vG < 128 * 5)
					{
						pHumanPlayer->vCount++;
						if (pHumanPlayer->vvi == 0)
						{
							pDataHumans->vFlagHelp1 = FALSE;
						}
						if (pHumanPlayer->vvi == 1)
						{
							pDataHumans->vFlagHelp2 = FALSE;
						}
					}
					else
					if (pHumanPlayer->vG < 128 * 7)
					{
						pHumanPlayer->vCount++;
						if (pHumanPlayer->vvi == 0)
						{
							pDataHumans->vFlagHelp1 = FALSE;
						}
						if (pHumanPlayer->vvi == 1)
						{
							pDataHumans->vFlagHelp2 = FALSE;
						}
					}
					else
					if (pHumanPlayer->vG < 128 * 10)
					{
						pHumanPlayer->vCount++;
						if (pHumanPlayer->vvi == 0)
						{
							pDataHumans->vFlagHelp1 = FALSE;
						}
						if (pHumanPlayer->vvi == 1)
						{
							pDataHumans->vFlagHelp2 = FALSE;
						}
					}
				}
			}
			else if (pHumanPlayer->vParamPlayer.vTimerGetElapsed > 60*1)
			{
				pHumanPlayer->vNoVamp = TRUE;
				/*if (pHumanPlayer->vvi == 0)
				{
					pDataHumans->vFlagHelp1 = FALSE;
				}
				if (pHumanPlayer->vvi == 1)
				{
					pDataHumans->vFlagHelp2 = FALSE;
				}*/
			}
		}
		if (pHumanPlayer->vNoVamp == TRUE && pHumanPlayer->vCount == 1)
		{
			pDataHumans->vBaseHelp2Wall = pDataHumans->vBaseHelp1Wall;
			pHumanPlayer->vCount++;
		}
		if (pHumanPlayer->vCount == 1)
		if (pDataHumans->vFlagHelp1 == FALSE)
		{
			pDataHumans->vFlagHelp1 = TRUE;
			pDataHumans->vBaseHelp1 = &pHumanPlayer->vBase;
			//pHumanPlayer->vHelp = TRUE;
		}
		else if (pDataHumans->vFlagHelp2 == FALSE)
		{
			pDataHumans->vFlagHelp2 = TRUE;
			pDataHumans->vBaseHelp2 = &pHumanPlayer->vBase;
			//pHumanPlayer->vHelp = TRUE;
		}
		if (pHumanPlayer->vCount == 2)
		{
			pDataHumans->vFlagHelp1 = TRUE;
			pDataHumans->vBaseHelp1 = &pHumanPlayer->vBase;
			pDataHumans->vFlagHelp2 = TRUE;
			pDataHumans->vBaseHelp2 = &pHumanPlayer->vBase;
			//return;
			//pHumanPlayer->vHelp = TRUE;
		}
	}
	if (pHumanPlayer->vBase.vSlayerBaze == FALSE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Atakovan == TRUE &&
		((pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId != ID_UNIT_BUILD_WALL_YELLOW &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId != ID_UNIT_BUILD_WALL_VIOLET) ||
		(pHumanPlayer->vParamPlayer.vTimerGetElapsed < 60*12 &&
		((pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_YELLOW &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vIdTrain == ID_UNIT_BUILD_WALL_VIOLET &&
		(pHumanPlayer->vParamPlayer.vTimerGetElapsed > pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vTimeEndTrain - 1)) ||
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET))))
	{
		if (vDataUnits[10].pDataUnit && IsUnitVisible(vDataUnits[10].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == FALSE)	
		if (pDataHumans->vFlagHelp1 == FALSE)
		{
			pDataHumans->vFlagHelp1 = TRUE;
			pDataHumans->vBaseHelp1 = &pHumanPlayer->vBase;
			pDataHumans->vBaseHelp1Wall = &pHumanPlayer->vBase;
			//pHumanPlayer->vHelp = TRUE;
		}
		if (vDataUnits[11].pDataUnit && IsUnitVisible(vDataUnits[11].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == FALSE)	
		if (pDataHumans->vFlagHelp2 == FALSE)
		{
			pDataHumans->vFlagHelp2 = TRUE;
			pDataHumans->vBaseHelp2 = &pHumanPlayer->vBase;
			pDataHumans->vBaseHelp2Wall = &pHumanPlayer->vBase;
			//pHumanPlayer->vHelp = TRUE;
		}
	}
	if (pDataHumans->vBaseHelp1 && pDataHumans->vBaseHelp1->vNBase == DO_NOT_FIND_BASE)
	{
		pDataHumans->vBaseHelp1 = NULL;
		pDataHumans->vBaseHelp1Wall = NULL;
	}
	if (pDataHumans->vBaseHelp2 && pDataHumans->vBaseHelp2->vNBase == DO_NOT_FIND_BASE)
	{
		pDataHumans->vBaseHelp2 = NULL;
		pDataHumans->vBaseHelp2Wall = NULL;
	}
	if (pHumanPlayer->vParamPlayer.vTimerGetElapsed < 12 * 60 &&
		(&pHumanPlayer->vBase == pDataHumans->vBaseHelp1 ||
		&pHumanPlayer->vBase == pDataHumans->vBaseHelp2))
	{
		pHumanPlayer->vBase.vSlayerDefense = TRUE;
	}
	else
	{
		pHumanPlayer->vBase.vSlayerDefense = FALSE;
	}
}

// Ченим юнит юнитом
bool fRepairUnitByUnit(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, DataUnit *pDataUnit2)
{
	if (pHumanPlayer == NULL || pDataUnit == NULL) return FALSE;
	if (pDataUnit2 == NULL)
	{
		pDataUnit->vHelping = FALSE;
		pDataUnit->vHelpBase = NULL;
		pDataUnit->vStageHelp = 0;
		return FALSE;
	}
	// Особождаем бинд, кому помогаем
	if (pDataUnit->vHelpingReset == TRUE)
	{
		for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
		{
			if (vMapBases.fFreeBindNPlayerHelp(&pHumanPlayerGlobal[pHumanPlayer->vvi].vBase,pHumanPlayer->vParamPlayer.vAI) == TRUE)
			{
				break;
			}
		}
		pDataUnit->vHelpingReset = FALSE;
	}
	if (pDataUnit->vHelping == TRUE &&
		pDataHumans->vBaseHelp1 == NULL &&
		pDataHumans->vBaseHelp2 == NULL &&
		pDataUnit->vHelpBase &&
		pDataUnit->vHelpBase->vNBase == DO_NOT_FIND_BASE &&
		pDataUnit->vHelpBase != &pHumanPlayer->vBase &&
		fIsMainHuman(pDataUnit->vId))
	{
		pDataUnit->vHelpBase = NULL;
		//pDataUnit->vStageHelp = 7;
	}
	if (
		(
		(pDataUnit->vHelping == TRUE && pDataHumans->vBaseHelp1 && pDataHumans->vBaseHelp1 != pDataUnit->vHelpBase) ||
		(pDataUnit->vHelping == FALSE && pDataHumans->vFlagHelp1 == TRUE && pDataHumans->vBaseHelp1 != NULL && pDataHumans->vBaseHelp1->vNBase != DO_NOT_FIND_BASE &&
		((!fIsMainHuman(pDataUnit->vId) && pDataHumans->vBaseHelp1Wall == pDataHumans->vBaseHelp1) ||
		(fIsMainHuman(pDataUnit->vId) && pDataHumans->vBaseHelp1 && pDataHumans->vBaseHelp1->fQBindNPlayerHelp() < 6)))
		) &&
		(
		pHumanPlayer->vBase.vSlayerBaze == TRUE ||
		(pHumanPlayer->vBase.vSlayerBaze == FALSE &&
		//((pHumanPlayer->vParamPlayer.vStage >= 74 &&
		//pHumanPlayer->vParamPlayer.vStage <= 81) ||
		//pHumanPlayer->vParamPlayer.vStage >= 83))) &&
		1)
		) &&
		pDataHumans->vBaseHelp1->vWallCreated &&
		((fIsTwoVampires() == FALSE ||
		(fIsTwoVampires() == TRUE &&
		pHumanPlayer->vParamPlayer.vAI >= 0 &&
		pHumanPlayer->vParamPlayer.vAI <= 5) &&
		fIsMainHuman(pDataUnit->vId)) ||
		pDataUnit->vId == ID_UNIT_URSA))
	{
		pDataUnit->vHelping = TRUE;
		pDataUnit->vHelpBase = pDataHumans->vBaseHelp1;
		pDataUnit->vStageHelp = 0;
		/*if (pDataUnit->vHelpBase->fQPosRepairFree() > 0)
		{
			pDataUnit->vStageHelp = 3;
		}*/
	}
	if (
		(
		(pDataUnit->vHelping == TRUE && pDataHumans->vBaseHelp2 && pDataHumans->vBaseHelp2 != pDataUnit->vHelpBase) ||
		(pDataUnit->vHelping == FALSE && pDataHumans->vFlagHelp2 == TRUE && pDataHumans->vBaseHelp2 != NULL && pDataHumans->vBaseHelp2->vNBase != DO_NOT_FIND_BASE &&
		((!fIsMainHuman(pDataUnit->vId) && pDataHumans->vBaseHelp2Wall == pDataHumans->vBaseHelp2) ||
		(fIsMainHuman(pDataUnit->vId) && pDataHumans->vBaseHelp2 && pDataHumans->vBaseHelp2->fQBindNPlayerHelp() < 6)))
		) &&
		(
		pHumanPlayer->vBase.vSlayerBaze == TRUE ||
		(pHumanPlayer->vBase.vSlayerBaze == FALSE &&
		//((pHumanPlayer->vParamPlayer.vStage >= 74 &&
		//pHumanPlayer->vParamPlayer.vStage <= 81) ||
		//pHumanPlayer->vParamPlayer.vStage >= 83))) &&
		1)
		) &&
		pDataHumans->vBaseHelp2->vWallCreated && 
		((fIsTwoVampires() == FALSE ||
		(fIsTwoVampires() == TRUE &&
		pHumanPlayer->vParamPlayer.vAI >= 6 &&
		pHumanPlayer->vParamPlayer.vAI <= 9) &&
		fIsMainHuman(pDataUnit->vId)) ||
		pDataUnit->vId == ID_UNIT_URSA))
	{
		pDataUnit->vHelping = TRUE;
		pDataUnit->vHelpBase = pDataHumans->vBaseHelp2;
		pDataUnit->vStageHelp = 0;
		/*if (pDataUnit->vHelpBase->fQPosRepairFree() > 0)
		{
			pDataUnit->vStageHelp = 3;
		}*/
	}
	if (pDataUnit->vHelping == FALSE &&
		pDataUnit->vAction == ACTION_WAITING &&
		pHumanPlayer->vStage <= 300 &&
		GetUnitCurrentOrder(pDataUnit->WhichUnit) == 0 &&
		(pHumanPlayer->vParamPlayer.vTimerGetElapsed > (60 * 2)))
	{
		if (fIsBaseHuman(pDataUnit,pHumanPlayer) == FALSE)
		{
			pDataUnit->vHelping = TRUE;
			pDataUnit->vHelpBase = NULL;
			pDataUnit->vStageHelp = 7;
		}
	}
	if (pDataUnit->vHelping == TRUE)
	switch (pDataUnit->vStageHelp)
	{
	case 0:
		// Приблинкаться на базу для помощи.
		//
		// Засекаем время отправки на базу
		if (pDataUnit2 &&
			fIsVampireNearby(pDataUnit2,pHumanPlayer) == TRUE &&
			((pDataUnit->vHelpBase == pDataHumans->vBaseHelp1) ||
			(pDataUnit->vHelpBase == pDataHumans->vBaseHelp2)))
		{
			pDataUnit->vTimeSignalToHelp = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
		}
		// Вовзращаемся обратно спустя какое-то время
		if (((pDataHumans->vBaseHelp1 == NULL &&
			pDataHumans->vBaseHelp2 == NULL &&
			fIsMainHuman(pDataUnit->vId)) ||
			fIsMainHuman(pDataUnit->vId) == FALSE) &&
			(pDataUnit->vTimeSignalToHelp == 0 ||
			pDataUnit->vTimeSignalToHelp != 0 &&
			(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pDataUnit->vTimeSignalToHelp > 90 && fIsMainHuman(pDataUnit->vId)) ||
			(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pDataUnit->vTimeSignalToHelp > 5 && pDataUnit->vId == ID_UNIT_URSA)))
		{
			// Обнулить атаку вампира
			/*if (pDataHumans->vBaseHelp1 == pDataUnit->vHelpBase)
			{
				pDataHumans->vBaseHelp1 = NULL;
				pDataHumans->vFlagHelp1 = FALSE;
			}
			if (pDataHumans->vBaseHelp2 == pDataUnit->vHelpBase)
			{
				pDataHumans->vBaseHelp2 = NULL;
				pDataHumans->vFlagHelp2 = FALSE;
			}*/
			// Ждём 10 маны мейн хуману
			pHumanPlayer->vMana = GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA);
			if (((unsigned int)pHumanPlayer->vMana < 10 && fIsMainHuman(pDataUnit->vId)) ||
				((unsigned int)pHumanPlayer->vMana < 1 && pDataUnit->vId == ID_UNIT_URSA))
			{
				goto m1;
			}
			//pDataUnit->vHelpBase = NULL;
			pDataUnit->vTimeSignalToHelp = 0;
			pDataUnit->vStageHelp = 13;
			goto m1;
			//pDataUnit->vStageHelp = 12;
			//goto m1;
		}
		// Если хелп база ноль или база разрушена, то уходим с базы
		if (pDataUnit->vHelpBase != NULL &&
			pDataUnit->vHelpBase->vNBase == DO_NOT_FIND_BASE)
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Если база разрушена или хуман сбежал, то уходим с базы
		if (pDataUnit->vHelpBase == NULL)// ||
			//(pDataUnit->vHelpBase && pDataUnit->vHelpBase->vNBase == DO_NOT_FIND_BASE))
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Вал сломан
		if (pDataUnit2 == NULL ||
			pDataUnit->vHelpBase->vWallCreated == FALSE)
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Найти безопасную зону на базе
		if (pDataHumans->vBaseHelp1 ||
			pDataHumans->vBaseHelp2)
		{
			fGriveZone(pDataUnit,pHumanPlayer);
			pDataUnit->vInt3 = vMapBases.fFindPosSafeZone(pDataUnit->vHelpBase);
			if (pDataUnit->vInt3 != vSizeMap)
			{
				pDataUnit->vStageHelp++;
				/*if (pDataUnit->vPosRepair > 0)
				{
					vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					pDataUnit->vPosRepair = 0;
				}*/
				fFinishActionUnit(pDataUnit->vIdDataUnit);
				// Освобождаем бинд помощи игроку
				for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
				{
					if (vMapBases.fFreeBindNPlayerHelp(&pHumanPlayerGlobal[pHumanPlayer->vvi].vBase,pHumanPlayer->vParamPlayer.vAI) == TRUE)
					{
						break;
					}
				}
				// Создаём новый бинд помощи игроку
				if (vMapBases.fBindNPlayerHelp(pDataUnit->vHelpBase,pHumanPlayer->vParamPlayer.vAI) == FALSE)
				{
					pDataUnit->vStageHelp = pDataUnit->vStageHelp;
				}
			}
			else
			{
				// Уйти с базы, если не нашли безопасную зону на базе, которой попогаем
				pDataUnit->vStageHelp = 7;
			}
		}
		goto m1;
	case 1:
		// Фаза блинков к базе
		// База разрушена, то уходим с базы
		if (pDataUnit->vHelpBase != NULL &&
			pDataUnit->vHelpBase->vNBase == DO_NOT_FIND_BASE)
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Если база разрушена или хуман сбежал, то уходим с базы
		if (pDataUnit->vHelpBase == NULL)
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Вал сломан
		if (pDataUnit2 == NULL ||
			pDataUnit->vHelpBase->vWallCreated == FALSE)
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Приблинкаться в безопасную зону на базе, которой помогаем
		if (fGoToAction(pDataUnit->vIdDataUnit,pDataUnit->vInt3,ACTION_BLINK) == 1)
		{
			/*if (pDataUnit->vPosRepair > 0)
			{
				//vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				pDataUnit->vPosRepair = 0;
			}*/
			pDataUnit->vStageHelp++;
		}
		goto m1;
	case 2:
		// Блинкуемся на базу, которой помогаем.
		//
		// Если хелп база ноль или база разрушена, то уходим с базы
		if (pDataUnit->vHelpBase == NULL ||
			(pDataUnit->vHelpBase != NULL &&
			pDataUnit->vHelpBase->vNBase == DO_NOT_FIND_BASE))
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Вал сломан
		if (pDataUnit2 == NULL ||
			pDataUnit->vHelpBase->vWallCreated == FALSE)
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Если не хватает хипов то лечимся
		if (GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_LIFE) >
			(GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.8))
		// Если мы на базе, то финиш и следующий стейдж
		if (pDataUnit->vHelpBase != NULL &&
			pDataUnit->vActionFinish == 1 &&
			fFindBaseByDataUnitNoEnemy(pDataUnit) == pDataUnit->vHelpBase->vNBase &&
			vMapBases.fRemotenessBase(fConverterIX2RX(pDataUnit->vRect1.vX1),fConverterIY2RY(pDataUnit->vRect1.vY1)) > 0)
		{
			fFinishActionUnit(pDataUnit->vIdDataUnit);
			pDataUnit->vStageHelp++;
			goto m1;
		}
		// Если мы финишировали но мы не на базе, то нулевой стейдж
		if (pDataUnit->vHelpBase != NULL &&
			pDataUnit->vInt3 == pDataUnit->vIntForGoTo &&
			pDataUnit->vActionFinish == 1 &&
			//fFindBaseByDataUnitNoEnemy(pDataUnit) != pDataUnit->vHelpBase->vNBase &&
			vMapBases.fRemotenessBase(fConverterIX2RX(pDataUnit->vRect1.vX1),fConverterIY2RY(pDataUnit->vRect1.vY1)) <= 0)
		{
			fFinishActionUnit(pDataUnit->vIdDataUnit);
			pDataUnit->vStageHelp = 0;
			goto m1;
		}
		// Если не хватает хипов то лечимся
		if (GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_LIFE) >
			(GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.8))
		// Если мы около вала, то финиш и следующий стейдж
		if (pDataUnit->vPosRepair == 0 &&
			pDataUnit->vHelpBase &&
			pDataUnit->vAction != ACTION_WAITING &&
			pDataUnit->vHelpBase->fQPosRepairBindFree() > 0)
		{
			if (pDataUnit2 &&
				fG(pDataUnit->LastCoordinates.X,
				   pDataUnit->LastCoordinates.Y,
				   pDataUnit2->LastCoordinates.X,
				   pDataUnit2->LastCoordinates.Y) <
				128*14)
			{
				pHumanPlayer->vMana = GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA);
				if (((unsigned int)pHumanPlayer->vMana >= 1 && fIsMainHuman(pDataUnit->vId)) ||
					((unsigned int)pHumanPlayer->vMana >= 1 && pDataUnit->vId == ID_UNIT_URSA))
				{
					fFinishActionUnit(pDataUnit->vIdDataUnit);
					pDataUnit->vStageHelp++;
					goto m1;
				}
			}
			else
			{
				pDataUnit->vStageHelp = pDataUnit->vStageHelp;
				//fFinishActionUnit(pDataUnit->vIdDataUnit);
				//pDataUnit->vStageHelp++;
				//goto m1;
			}
		}
		// Если время сигнала вышло, то уходим с базы
		if (pDataHumans->vBaseHelp1 == NULL &&
			pDataHumans->vBaseHelp2 == NULL &&
			(pDataUnit->vTimeSignalToHelp == 0 ||
			(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pDataUnit->vTimeSignalToHelp > 90)))
		{
			pDataUnit->vStageHelp = 0;
			goto m1;
		}
		/*if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vActionFinish == 0)
		{
			goto m1;
		}
		else
		{
			pHumanPlayer->vStageHelp++;
		}*/
		// Если мы финишировали но мы не на базе, то нулевой стейдж
		if (pDataUnit->vHelpBase != NULL &&
			//pDataUnit->vInt3 == pDataUnit->vIntForGoTo &&
			pDataUnit->vAction == ACTION_WAITING &&
			pDataUnit->vActionFinish == 1// &&
			//fFindBaseByDataUnitNoEnemy(pDataUnit) != pDataUnit->vHelpBase->vNBase &&
			//vMapBases.fRemotenessBase(fConverterIX2RX(pDataUnit->vRect1.vX1),fConverterIY2RY(pDataUnit->vRect1.vY1)) > 0
			)
		{
			fFinishActionUnit(pDataUnit->vIdDataUnit);
			pDataUnit->vStageHelp = 0;
			goto m1;
		}
		goto m1;
	case 3:
		// Фаза мы на базе, найти позицию для починки вала
		//
		// Обнулить позицию ремонта вала
		/*if (pDataUnit->vPosRepair > 0)
		{
			vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
			vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
			pDataUnit->vPosRepair = 0;
		}*/
		// Если база разрушена, то уходим с базы
		if (pDataUnit->vHelpBase != NULL &&
			(pDataUnit->vHelpBase->pHumanPlayer == NULL ||
			pDataUnit->vHelpBase->vNBase == DO_NOT_FIND_BASE))
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Если отдали приказ отступать, то уходим с базы
		if (pDataUnit->vHelpBase == NULL)
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Если база есть, но она отличается от прежней то меняем ей и блинкуемся в безопасную зону
		if (pDataUnit->vHelpBase &&
			pDataHumans->vBaseHelp1 &&
			pDataHumans->vBaseHelp1 != pDataUnit->vHelpBase)
		{
			pDataUnit->vHelpBase = pDataHumans->vBaseHelp1;
			pDataUnit->vStageHelp = 0;
			goto m1;
		}
		if (pDataUnit->vHelpBase &&
			pDataHumans->vBaseHelp2 &&
			pDataHumans->vBaseHelp2 != pDataUnit->vHelpBase)
		{
			pDataUnit->vHelpBase = pDataHumans->vBaseHelp2;
			pDataUnit->vStageHelp = 0;
			goto m1;
		}
		// Вал сломан
		if (pDataUnit2 == NULL ||
			pDataUnit->vHelpBase->vWallCreated == FALSE)
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Если не хватает хипов то лечимся
		if (GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
			(GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.8))
		{
			goto m1;
		}
		// Проверить место для починки вала
		if (pDataUnit->vPosRepair > 0 &&
			vMapBases.fCheckPosBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair) == TRUE)
		{
			pHumanPlayer->vX_1 = pDataUnit->LastCoordinates.X;
			pHumanPlayer->vY_1 = pDataUnit->LastCoordinates.Y;
			pHumanPlayer->vX_2 = fGetMinIX2RX(fConvertIToX(pDataUnit->vPosRepair))+32;
			pHumanPlayer->vY_2 = fGetMinIY2RY(fConvertIToY(pDataUnit->vPosRepair))-32;
			pHumanPlayer->vG = fG(pHumanPlayer->vX_1,
								  pHumanPlayer->vY_1,
								  pHumanPlayer->vX_2,
								  pHumanPlayer->vY_2);
			if (pHumanPlayer->vG > 16)
			{
				fFreePosRepair(pDataUnit);
			}
		}
		// Найти место для починки вала и забиндить его
		pDataUnit->vInt3 = vMapBases.fFindPosRepair(pDataUnit->vHelpBase,pHumanPlayer);
		if (pDataUnit->vInt3 != vSizeMap)
		{
			pDataUnit->vPosRepair = pDataUnit->vInt3;
			//vMapBases.fPosRepairTrue(pDataUnit->vHelpBase,pDataUnit->vInt3);
			fFinishActionUnit(pDataUnit->vIdDataUnit);
			pDataUnit->vStageHelp++;
			goto m1;
		}
		//else if (pDataUnit->vHelpBase &&
		//		 fFindBaseByDataUnitNoEnemy(pDataUnit) != pDataUnit->vHelpBase->vNBase)
		//{
			pDataUnit->vStageHelp = 11;
		//}
		//else
		//{
		//	pHumanPlayer->vStageHelp = pHumanPlayer->vStageHelp;
			//pHumanPlayer->vStageHelp = 0;
		//}
		goto m1;
	case 4:
			pHumanPlayer->vX_1 = pDataUnit->LastCoordinates.X;
			pHumanPlayer->vY_1 = pDataUnit->LastCoordinates.Y;
			pHumanPlayer->vX_2 = fGetMinIX2RX(fConvertIToX(pDataUnit->vPosRepair))+32;
			pHumanPlayer->vY_2 = fGetMinIY2RY(fConvertIToY(pDataUnit->vPosRepair))-32;
			pHumanPlayer->vG = fG(pHumanPlayer->vX_1,
								  pHumanPlayer->vY_1,
								  pHumanPlayer->vX_2,
								  pHumanPlayer->vY_2);
		// Приблинкаться к валу
		if (fGoToAction(pDataUnit->vIdDataUnit,pDataUnit->vInt3,pHumanPlayer->vG > 65 ? ACTION_BLINK : ACTION_GO) == 1)
		{
			//IssueImmediateOrderById(pDataUnit->WhichUnit,ID_ORDER_STOP);
			pDataUnit->vStageHelp++;
		}
		goto m1;
	case 5:
		// Пока блинкуемся в валу
		//
		// Если база разрушена, то уходим с базы
		if (pDataUnit->vHelpBase == NULL ||
			(pDataUnit->vHelpBase &&
			pDataUnit->vHelpBase->vNBase == DO_NOT_FIND_BASE))
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Вал сломан
		if (pDataUnit2 == NULL ||
			pDataUnit->vHelpBase->vWallCreated == FALSE)
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Если мы около вала и маны нету, то стоим ждём ману
		/*if (pDataUnit->vHelpBase &&
			pDataUnit->vAction == ACTION_GO &&
			pDataUnit2 &&
			fG(pDataUnit->LastCoordinates.X,
			   pDataUnit->LastCoordinates.Y,
			   pDataUnit2->LastCoordinates.X,
			   pDataUnit2->LastCoordinates.Y) <
			128*13)
		{
			pHumanPlayer->vMana = GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA);
			if (((unsigned int)pHumanPlayer->vMana < 1 && fIsMainHuman(pDataUnit->vfId)) ||
				((unsigned int)pHumanPlayer->vMana < 1 && pDataUnit->vId == ID_UNIT_URSA))
			{
				IssueImmediateOrderById(pDataUnit->WhichUnit,ID_ORDER_STOP);
				goto m1;
			}
		}*/
		if (pDataUnit->vPosRepair > 0 &&
			vMapBases.fCheckPosBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair) == FALSE)
		{
			pHumanPlayer->vX_1 = pDataUnit->LastCoordinates.X;
			pHumanPlayer->vY_1 = pDataUnit->LastCoordinates.Y;
			pHumanPlayer->vX_2 = fGetMinIX2RX(fConvertIToX(pDataUnit->vPosRepair))+32;
			pHumanPlayer->vY_2 = fGetMinIY2RY(fConvertIToY(pDataUnit->vPosRepair))-32;
			pHumanPlayer->vG = fG(pHumanPlayer->vX_1,
								  pHumanPlayer->vY_1,
								  pHumanPlayer->vX_2,
								  pHumanPlayer->vY_2);
			if (//pHumanPlayer->vMainHuman.vManaBurn.vCast == TRUE &&
				pHumanPlayer->vG <= 16)
			{
				vMapBases.fPosBindTrue(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				//vMapBases.fPosRepairTrue(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				fFinishActionUnit(pDataUnit->vIdDataUnit);
				//pHumanPlayer->vMainHuman.vManaBurn.vCast = FALSE;
				//pDataUnit->vInt3 = pDataUnit->vPosRepair;
				pDataUnit->vStageHelp++;
				goto m1;
			}
			//else if (pHumanPlayer->vG < 128)
			//{
				//vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				//vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				//pDataUnit->vPosRepair = 0;
				//fFinishActionUnit(pDataUnit->vIdDataUnit);
				//pDataUnit->vStageHelp = 0;
				//goto m1;
			//}
		}
		
		//GetUnitCurrentOrder
		if (pHumanPlayer->vMainHuman.vManaBurn.vCast == TRUE)
		{
			pHumanPlayer->vMainHuman.vManaBurn.vCast = FALSE;
			fFinishActionUnit(pDataUnit->vIdDataUnit);
			pDataUnit->vStageHelp = 0;
			goto m1;
		}
		if (pDataUnit->vAction != ACTION_WAITING &&
			pDataUnit->vActionFinish == 0)
		{
			goto m1;
		}
		/*if (pDataUnit->vAction == ACTION_WAITING &&
			pDataUnit->vActionFinish == 1)
		{
			fFinishActionUnit(pDataUnit->vIdDataUnit);
			pDataUnit->vStageHelp = 0;
			goto m1;
		}*/
		// Зафиксировать позицию мове
		/*if (pDataUnit->PermissionMove == TRUE)
		{
			pDataUnit->PermissionMove = FALSE;
		}
		// Зафиксировать позицию разрешения каставать
		if (pDataUnit->Permission == TRUE)
		{
			pDataUnit->Permission = FALSE;
		}*/
		fFinishActionUnit(pDataUnit->vIdDataUnit);
		pDataUnit->vStageHelp++;
		goto m1;
	case 6:
		// Фаза около вала.
		//
		// Если нет позиции ремонта
		if (pDataUnit->vPosRepair == 0)
		{
			pDataUnit->vStageHelp = 0;
			goto m1;
		}
		// Если мало хипов то прыгаем в безопасную зону и стоим на месте.
		if (GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
			(GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.55))
		{
			/*if (pDataUnit->vPosRepair > 0)
			{
				vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				pDataUnit->vPosRepair = 0;
			}*/
			pDataUnit->vStageHelp = 0;
			goto m1;
		}
		// Если база разрушена, то уходим с базы
		if (pDataUnit->vHelpBase == NULL ||
			(pDataUnit->vHelpBase &&
			pDataUnit->vHelpBase->vNBase == DO_NOT_FIND_BASE))
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Вал сломан
		if (pDataUnit2 == NULL ||
			pDataUnit->vHelpBase->vWallCreated == FALSE)
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		// Позиция починки есть, то проверяем, как мы стоим в позиции для починки вала, если плохо стоим то прыгаем в позицию для починки вала снова или июдём туда,
		// если не можем прыгнуть.
		if (fIsMainHuman(pDataUnit->vId) &&
			((pHumanPlayer->vParamPlayer.vTimerGetElapsed >= 12 * 60) ||
			(pHumanPlayer->vParamPlayer.vTimerGetElapsed < 12 * 60 && pHumanPlayer->vMainHuman.vManaBurn.vCast == FALSE)) ||
			!fIsMainHuman(pDataUnit->vId))
		if (pDataUnit->vPosRepair > 0 &&
			vMapBases.fCheckPosBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair) == TRUE)
		{
			pHumanPlayer->vX_1 = pDataUnit->LastCoordinates.X;
			pHumanPlayer->vY_1 = pDataUnit->LastCoordinates.Y;
			pHumanPlayer->vX_2 = fGetMinIX2RX(fConvertIToX(pDataUnit->vPosRepair))+32;
			pHumanPlayer->vY_2 = fGetMinIY2RY(fConvertIToY(pDataUnit->vPosRepair))-32;
			pHumanPlayer->vG = fG(pHumanPlayer->vX_1,
								  pHumanPlayer->vY_1,
								  pHumanPlayer->vX_2,
								  pHumanPlayer->vY_2);
			// Если наше место кем то занято, то ищем позицию для починики вала заного
			if (pHumanPlayer->vG > 64 &&
				fCheckPos(pDataUnit,pDataUnit->vPosRepair) == FALSE)
			{
				//if (pDataUnit->vPosRepair > 0)
				//{
					//vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					//vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					//pDataUnit->vPosRepair = 0;
					fFinishActionUnit(pDataUnit->vIdDataUnit);
					pDataUnit->vStageHelp = 0;
					goto m1;
				//}
			}
			if (//pHumanPlayer->vMainHuman.vManaBurn.vCast == TRUE &&
				pHumanPlayer->vG > 23)
			{
				fFinishActionUnit(pDataUnit->vIdDataUnit);
				//pHumanPlayer->vMainHuman.vManaBurn.vCast = FALSE;
				//pDataUnit->vInt3 = pDataUnit->vPosRepair;
				pDataUnit->vStageHelp = 3;
				goto m1;
			}
		}
		// Мы стоим около вала и кастуем мана берн.
		//if (pDataUnit->vActionFinish == 0 &&
		//	pHumanPlayer->vMainHuman.vManaBurn.vCast == TRUE)
		//{
		//	goto m1;
		//}
		// Если мейн хуман и вал есть хелп база есть позиций для починки вала на базе больше 5 и хипов более 65% у вала то кастуем манабёрн по вампам.
		// или позиций для починки вала больше 2 и хипов у вала больше 90%, то кастуем мана бёрн по вампам.
		if (pHumanPlayer->vParamPlayer.vTimerGetElapsed < 12 * 60 &&
			fIsMainHuman(pDataUnit->vId) &&
			pDataUnit2 &&
			pDataUnit->vHelpBase &&
			((pDataUnit->vHelpBase->fQPosRepairBind() > 5 &&
			(GetUnitState(pDataUnit2->WhichUnit, UNIT_STATE_LIFE) >
			(GetUnitState(pDataUnit2->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.65))) ||
			(pDataUnit->vHelpBase->fQPosRepairBind() > 2 &&
			((GetUnitState(pDataUnit2->WhichUnit, UNIT_STATE_LIFE) >
			(GetUnitState(pDataUnit2->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.85))))))
		{
			if (fManaBurnToUnit(pHumanPlayer,pDataUnit,vDataUnits[10].pDataUnit) == TRUE) goto m1;
			if (fManaBurnToUnit(pHumanPlayer,pDataUnit,vDataUnits[11].pDataUnit) == TRUE) goto m1;
		}
		// Ремонтировать вал
		if (pDataUnit->vHelpBase)
		{
			if (fRepair(pHumanPlayer,
						pDataUnit,
						pDataUnit2) == TRUE)
			{
				//if (pDataUnit->vPosRepair > 0)
				//{
				//	vMapBases.fFreePosRepair(pHumanPlayer->vHelpBase,pDataUnit->vPosRepair);
				//}
				/*if (pHumanPlayer->vHelpBase->vFreeAllRepairPos == FALSE)
				{
					vMapBases.fFreeAllPosRepair(pHumanPlayer->vHelpBase);
				}*/
				fFinishActionUnit(pDataUnit->vIdDataUnit);
				//pHumanPlayer->vStageHelp += 2;
				// Освободить позицию ремонта
				// Если отремонтировали то идём на 11 фазу
				pDataUnit->vStageHelp = 11;
				goto m1;
			}
			else
			{
				/*if (pDataUnit2)
				{
					pHumanPlayer->vG = fG(pDataUnit->LastCoordinates.X,pDataUnit->LastCoordinates.Y,pDataUnit2->LastCoordinates.X,pDataUnit2->LastCoordinates.Y);
					if (pHumanPlayer->vG > 200)
					{
						fFinishActionUnit(pDataUnit->vIdDataUnit);
						pDataUnit->vStageHelp = 4;
						goto m1;
					}
				}*/
				/*if (pDataUnit->vPosRepair > 0)
				{
					vMapBases.fPosRepairTrue(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				}*/
				pDataUnit->vTimeSignalToHelp = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
				//pHumanPlayer->vTimeAttackWall = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
			}
		}
		else
		{
			
			// Если отдали приказ отступать
			if (pDataUnit->vHelpBase == NULL ||
				(pDataHumans->vBaseHelp1 &&
				pDataHumans->vBaseHelp1 != pDataUnit->vHelpBase &&
				pDataHumans->vBaseHelp2 &&
				pDataHumans->vBaseHelp2 != pDataUnit->vHelpBase))
			{
				pDataUnit->vStageHelp = 7;
				goto m1;
			}
		}
		// Если время сигнала вышло, то уходим с базы
		if (pDataUnit->vTimeSignalToHelp == 0 ||
			(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pDataUnit->vTimeSignalToHelp > 90))
		{
			pDataUnit->vStageHelp = 7;
			goto m1;
		}
		goto m1;
	case 7:
		// Уходим с базы на ближайшую базу или на свою или на денс пул
		//
		// Расфиксировать позицию мове
		/*if (pDataUnit->PermissionMove == FALSE)
		{
			pDataUnit->PermissionMove = TRUE;
		}*/
		/*if (pDataUnit->vPosRepair > 0)
		{
			vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
			vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
			pDataUnit->vPosRepair = 0;
		}*/
		//vMapBases.fFreePosRepair(pHumanPlayer->vHelpBase,pHumanPlayer->vInt3);
		// Обнулить переменные и позицию ремонта вала
		//pHumanPlayer->vStageHelp = 0;
		//pHumanPlayer->vHelping = FALSE;
		fFinishActionUnit(pDataUnit->vIdDataUnit);
		// Обозначим вал сломаным
		if (pDataUnit->vHelpBase)
		{
			pDataUnit->vHelpBase->vWallCreated = FALSE;
		}
		// Свалить
		// Найти ближайшую базу
		pHumanPlayer->vNBase = fFindNearestBase(pHumanPlayer,pDataUnit);
		if (pHumanPlayer->vNBase != DO_NOT_FIND_BASE)
		{
			pDataUnit->vInt3 = vSizeMap;
			for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
			{
				if (pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBase == pHumanPlayer->vNBase)
				{
					pDataUnit->vInt3 = vMapBases.fFindPosSafeZone(&pHumanPlayerGlobal[pHumanPlayer->vvi].vBase);
					break;
				}
			}
			if (pDataUnit->vInt3 != vSizeMap)
			{
				// Блинкаемся к ближайшей базе
				if (fGoToAction(pDataUnit->vIdDataUnit,pDataUnit->vInt3,ACTION_BLINK) == 1)
				{
					if (pDataUnit->vPosRepair > 0)
					{
						//vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
						vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
						pDataUnit->vPosRepair = 0;
					}
					pDataUnit->vStageHelp = 16;
					pDataUnit->vHelpingReset = TRUE;

					/*if (fRemotenessBase(pDataUnit) > 5 &&
						fIsBaseHuman(pDataUnit,pHumanPlayer) == TRUE)
					{
						pDataUnit->vInt3 = fMaxRemotenessBase(pDataUnit);
						pDataUnit->pPut->vRect6.vX1 = fConvertIToX(pDataUnit->vInt3);
						pDataUnit->pPut->vRect6.vY1 = fConvertIToY(pDataUnit->vInt3);
						pDataUnit->pPut->vRect6.vX2 = pDataUnit->pPut->vRect6.vX1 + pDataUnit->pPut->vDiff - 1;
						pDataUnit->pPut->vRect6.vY2 = pDataUnit->pPut->vRect6.vY1 + pDataUnit->pPut->vDiff - 1;
						fIssuePointOrderToRect(pDataUnit->WhichUnit,
											   "move",
											   &pDataUnit->pPut->vRect6,
											   pDataUnit->pPut->vRadius_Unit);
					}*/
					goto m1;
				}
			}
			else
			{
				if (pHumanPlayer->vFlagDearBase == TRUE)
				{
					//pDataUnit->vInt3 = vMapBases.fFindPosSafeZone(&pHumanPlayer->vBase);
					// Приблинкаться на свою базу если она есть.
					//if (fGoToAction(pDataUnit->vIdDataUnit,pDataUnit->vInt3,ACTION_BLINK) == 1)
						pDataUnit->vStageHelp = 13;
						pDataUnit->vHelpingReset = TRUE;
						goto m1;
				}
			}
		}
		else
		{
			pHumanPlayer->vBase.vNBase = DO_NOT_FIND_BASE;
			if (fFindIToMapCenter(JASS_DANCEPOOL,&pHumanPlayer->vX_1,&pHumanPlayer->vY_1) == FALSE) return FALSE;
			pHumanPlayer->vX = fConverterX(pHumanPlayer->vX_1);
			pHumanPlayer->vY = fConverterY(pHumanPlayer->vY_1);
			pDataUnit->vInt3 = fConvertXYToI(pHumanPlayer->vX,
												pHumanPlayer->vY);
			if (pDataUnit->vInt3 == vSizeMap)
			{
				return FALSE;
			}
			// Бликнуться к денс пулу
			if (fGoToAction(pDataUnit->vIdDataUnit,pDataUnit->vInt3,ACTION_BLINK) == 1)
			{
				if (pDataUnit->vPosRepair > 0)
				{
					//vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					pDataUnit->vPosRepair = 0;
				}
				pDataUnit->vStageHelp = 16;
				pDataUnit->vHelpingReset = TRUE;
			}
			goto m1;
		}
		return FALSE;
		goto m1;
	case 8:
		// Найти безопасную зону
		//pDataUnit->vInt3 = vMapBases.fFindPosSafeZone(pDataUnit->vHelpBase);
		//if (pDataUnit->vInt3 != vSizeMap)
		//{
			pDataUnit->vStageHelp++;
		//}
		//else
		//{
		//	pDataUnit->vStageHelp+= 2;
		//}
		goto m1;
	case 9:
		// Бликнуться в безопасную зону
		//if (fGoToAction(pDataUnit->vIdDataUnit,pDataUnit->vInt3,ACTION_BLINK) == 1)
			pDataUnit->vStageHelp++;
		goto m1;
	case 10:
		// Фаза: подождать 10 маны, как дождались идём на нулевую фазу
		//
		// Ждём 10 маны мейн хуману
		pHumanPlayer->vMana = GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA);
		if (((unsigned int)pHumanPlayer->vMana < 10 && fIsMainHuman(pDataUnit->vId)) ||
			((unsigned int)pHumanPlayer->vMana < 1 && pDataUnit->vId == ID_UNIT_URSA))
		{
			goto m1;
		}
		else
		{
			pDataUnit->vStageHelp = 0;
		}
		goto m1;
		/*if (pDataUnit->vPosRepair > 0)
		{
			vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
			pDataUnit->vPosRepair = 0;
		}*/
		// Расфиксировать позицию мове
		/*if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->PermissionMove == FALSE)
		{
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->PermissionMove = TRUE;
		}*/
		//pDataUnit->vStageHelp++;
		//goto m1;
	case 11:
		// Засекаем время видимости вампира
		if (pDataUnit2 &&
			fIsVampireNearby(pDataUnit2,pHumanPlayer) == TRUE &&
			((pDataUnit->vHelpBase == pDataHumans->vBaseHelp1) ||
			(pDataUnit->vHelpBase == pDataHumans->vBaseHelp2)))
		{
			pDataUnit->vTimeSignalToHelp = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
		}
		// Вовзращаемся обратно спустя какое-то время
		if (pDataUnit->vTimeSignalToHelp != 0 &&
			(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pDataUnit->vTimeSignalToHelp > 90 && fIsMainHuman(pDataUnit->vId)) ||
			(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pDataUnit->vTimeSignalToHelp > 5 && pDataUnit->vId == ID_UNIT_URSA))
		{
			// Обнулить атаку вампира
			if (fIsMainHuman(pDataUnit->vId))
			{
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Atakovan = FALSE;
				if (pDataHumans->vBaseHelp1 == pDataUnit->vHelpBase)
				{
					pDataHumans->vBaseHelp1 = NULL;
					pDataHumans->vBaseHelp1Wall = NULL;
					pDataHumans->vFlagHelp1 = FALSE;
				}
				if (pDataHumans->vBaseHelp2 == pDataUnit->vHelpBase)
				{
					pDataHumans->vBaseHelp2 = NULL;
					pDataHumans->vBaseHelp2Wall = NULL;
					pDataHumans->vFlagHelp2 = FALSE;
				}
			}
			// зафиксировать позицию мове
			if (pDataUnit->PermissionMove == TRUE)
			{
				pDataUnit->PermissionMove = FALSE;
			}
			pDataUnit->vStageHelp = 0;
			goto m1;
		}
		// Если вампир рядом с чужой базой, то идём помогать.
		if (fIsMainHuman(pDataUnit->vId))
		{
			if (pDataHumans->vBaseHelp1 &&
				pDataHumans->vBaseHelp1 != pDataUnit->vHelpBase)
			{
				/*if (pDataUnit->vPosRepair > 0)
				{
					vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					pDataUnit->vPosRepair = 0;
				}*/
				pDataUnit->vHelpingReset = TRUE;
				pHumanPlayer->vBaseAnAlly = fBase(pDataUnit,pHumanPlayer);
				if (pHumanPlayer->vBaseAnAlly &&
					pHumanPlayer->vBaseAnAlly->vQHeal == 0)
				{
					pDataUnit->vStageHelp = 0;
				}
				else
				{
					pDataUnit->vStageHelp = 10;
				}
				pDataUnit->vHelpBase = pDataHumans->vBaseHelp1;
				goto m1;
			}
			if (pDataHumans->vBaseHelp2 &&
				pDataHumans->vBaseHelp2 != pDataUnit->vHelpBase)
			{
				/*if (pDataUnit->vPosRepair > 0)
				{
					vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					pDataUnit->vPosRepair = 0;
				}*/
				pDataUnit->vHelpingReset = TRUE;
				pHumanPlayer->vBaseAnAlly = fBase(pDataUnit,pHumanPlayer);
				if (pHumanPlayer->vBaseAnAlly &&
					pHumanPlayer->vBaseAnAlly->vQHeal == 0)
				{
					pDataUnit->vStageHelp = 0;
				}
				else
				{
					pDataUnit->vStageHelp = 10;
				}
				pDataUnit->vHelpBase = pDataHumans->vBaseHelp2;
				goto m1;
			}
		}
		// Если рядом с базой
		if (pDataHumans->vBaseHelp1 &&
			pDataHumans->vBaseHelp1 == pDataUnit->vHelpBase)
		{
			pDataUnit->vStageHelp = 6;
			goto m1;
		}
		if (pDataHumans->vBaseHelp2 &&
			pDataHumans->vBaseHelp2 == pDataUnit->vHelpBase)
		{
			pDataUnit->vStageHelp = 6;
			goto m1;
		}
		// Снова чинить вал союзника
		//if (pDataHumans->vBaseHelp1 == pHumanPlayer->vHelpBase ||
		//	pDataHumans->vBaseHelp2 == pHumanPlayer->vHelpBase)
		/*if (pHumanPlayer->vHelpBase != NULL &&
			pHumanPlayer->vHelpBase->pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
			(GetUnitState(pHumanPlayer->vHelpBase->pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) -
			GetUnitState(pHumanPlayer->vHelpBase->pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE)) > 100)
		{
			if (pDataHumans->vTimeSignalToHelp == 0 ||
				(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pDataHumans->vTimeSignalToHelp > 60))
			{
				pDataHumans->vTimeSignalToHelp = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
			}
			//pHumanPlayer->vStageHelp = 2;
			pHumanPlayer->vStageHelp = 6;
			goto m1;
		}*/
		// Если отдали приказ отступать
		if (pDataUnit->vHelpBase == NULL ||
			(pDataHumans->vBaseHelp1 &&
			pDataHumans->vBaseHelp1 != pDataUnit->vHelpBase &&
			pDataHumans->vBaseHelp2 &&
			pDataHumans->vBaseHelp2 != pDataUnit->vHelpBase))
		{
			//pHumanPlayer->vStageHelp = 7;
			//pDataUnit->vHelpBase = NULL;
			/*if (pDataUnit->vPosRepair > 0)
			{
				vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				pDataUnit->vPosRepair = 0;
			}*/
			pDataUnit->vStageHelp = 0;
			//pDataUnit->vHelping = FALSE;
			goto m1;
		}
		goto m1;
	case 12:
		// Мы починили вал после атаки вампира
		//
		// Если рядом с чужой базой вампир, идём помогать
		if (fIsMainHuman(pDataUnit->vId))
		{
			if (pDataHumans->vBaseHelp1 &&
				pDataHumans->vBaseHelp1 != pDataUnit->vHelpBase)
			{
				/*if (pDataUnit->vPosRepair > 0)
				{
					vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					pDataUnit->vPosRepair = 0;
				}*/
				pDataUnit->vHelpingReset = TRUE;
				pHumanPlayer->vBaseAnAlly = fBase(pDataUnit,pHumanPlayer);
				if (pHumanPlayer->vBaseAnAlly &&
					pHumanPlayer->vBaseAnAlly->vQHeal == 0)
				{
					pDataUnit->vStageHelp = 0;
				}
				else
				{
					pDataUnit->vStageHelp = 10;
				}
				pDataUnit->vHelpBase = pDataHumans->vBaseHelp1;
				goto m1;
			}
			if (pDataHumans->vBaseHelp2 &&
				pDataHumans->vBaseHelp2 != pDataUnit->vHelpBase)
			{
				/*if (pDataUnit->vPosRepair > 0)
				{
					vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
					pDataUnit->vPosRepair = 0;
				}*/
				pDataUnit->vHelpingReset = TRUE;
				pHumanPlayer->vBaseAnAlly = fBase(pDataUnit,pHumanPlayer);
				if (pHumanPlayer->vBaseAnAlly &&
					pHumanPlayer->vBaseAnAlly->vQHeal == 0)
				{
					pDataUnit->vStageHelp = 0;
				}
				else
				{
					pDataUnit->vStageHelp = 10;
				}
				pDataUnit->vHelpBase = pDataHumans->vBaseHelp2;
				goto m1;
			}
		}
		// Если рядом с базой
		if (pDataHumans->vBaseHelp1 &&
			pDataHumans->vBaseHelp1 == pDataUnit->vHelpBase)
		{
			pDataUnit->vStageHelp = 6;
			goto m1;
		}
		if (pDataHumans->vBaseHelp2 &&
			pDataHumans->vBaseHelp2 == pDataUnit->vHelpBase)
		{
			pDataUnit->vStageHelp = 6;
			goto m1;
		}
		// Ждём 10 маны мейн хуману
		pHumanPlayer->vMana = GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA);
		if (((unsigned int)pHumanPlayer->vMana < 10 && fIsMainHuman(pDataUnit->vId)) ||
			((unsigned int)pHumanPlayer->vMana < 1 && pDataUnit->vId == ID_UNIT_URSA))
		{
			goto m1;
		}
		else
		{
			pDataUnit->vStageHelp++;
		}
		goto m1;
	case 13:
		// Фаза выбора обратного пути на свою базу
		//
		// Обнуляем позицию для починки вала
		/*if (pDataUnit->vPosRepair > 0)
		{
			vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
			vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
			pDataUnit->vPosRepair = 0;
		}*/
		// Обнуляем хелп базу
		//pDataUnit->vHelpBase = NULL;
		// Свалить мейн хуману на свою базу
		if (fIsMainHuman(pDataUnit->vId))
		{
			pDataUnit->vInt3 = vMapBases.fFindPosSafeZone(&pHumanPlayer->vBase);
			if (pDataUnit->vInt3 != vSizeMap)
			{
				fFinishActionUnit(pDataUnit->vIdDataUnit);
				pDataUnit->vStageHelp++;
			}
			else
			{
				pDataUnit->vStageHelp = 7;
			}
			pDataUnit->vHelpingReset = TRUE;
			goto m1;
		}
		// Блинкнуться урсе к дереву
		if (pDataUnit->vId == ID_UNIT_URSA)
		{
			pDataUnit->vInt3 = pDataUnit->vPosHarvesting;
			if (pDataUnit->vInt3 != vSizeMap)
			{
				fFinishActionUnit(pDataUnit->vIdDataUnit);
				pDataUnit->vStageHelp++;
			}
			else
			{
				pDataUnit->vStageHelp = 7;
			}
			pDataUnit->vHelpingReset = TRUE;
			goto m1;
		}
		goto m1;
	case 14:
		// Блинкаться на свою базу
		if (fGoToAction(pDataUnit->vIdDataUnit,pDataUnit->vInt3,ACTION_BLINK) == 1)
		{
			// Обнуляем позицию для починки вала
			/*if (pDataUnit->vPosRepair > 0)
			{
				//vMapBases.fFreePosRepair(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				vMapBases.fFreePosRepairBind(pDataUnit->vHelpBase,pDataUnit->vPosRepair);
				pDataUnit->vPosRepair = 0;
			}*/
			pDataUnit->vStageHelp++;
		}
		goto m1;
	case 15:
		if (pDataUnit->vHelpingReset == TRUE &&
			pDataUnit->vPosRepair > 0)
		{
			pHumanPlayer->vX_1 = pDataUnit->LastCoordinates.X;
			pHumanPlayer->vY_1 = pDataUnit->LastCoordinates.Y;
			pHumanPlayer->vX_2 = fGetMinIX2RX(fConvertIToX(pDataUnit->vPosRepair))+32;
			pHumanPlayer->vY_2 = fGetMinIY2RY(fConvertIToY(pDataUnit->vPosRepair))-32;
			pHumanPlayer->vG = fG(pHumanPlayer->vX_1,
								  pHumanPlayer->vY_1,
								  pHumanPlayer->vX_2,
								  pHumanPlayer->vY_2);
			if (pHumanPlayer->vG > 128)
			{
				// Особождаем бинд, кому помогаем
				for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
				{
					if (vMapBases.fFreeBindNPlayerHelp(&pHumanPlayerGlobal[pHumanPlayer->vvi].vBase,pHumanPlayer->vParamPlayer.vAI) == TRUE)
					{
						break;
					}
				}
				pDataUnit->vHelpingReset = FALSE;
			}
		}
		// Фаза проверки прибытия на свою базу
		if (pDataUnit->vActionFinish == 1)
		{
			// Строим хил пушки, как прибыли на базу
			pHumanPlayer->vBase.vBuildHeal = TRUE;
			pDataUnit->vStageHelp++;
		}
		goto m1;
	case 16:
		// Завершающая фаза
		//
		// Отправить урсу добывать лес
		if (pDataUnit->vId == ID_UNIT_URSA)
		{
			fHarvestingNearestTree(pDataUnit);
		}
		// Обнулить переменные
		pDataUnit->vHelpBase = NULL;
		pDataUnit->vStageHelp = 0;
		pDataUnit->vHelping = FALSE;
		pDataUnit->vHelpingReset = TRUE;
		goto m1;
	}
	return FALSE;
m1:
	return TRUE;
}

// Ченим вал
bool fBlinkToWall(HumanPlayer *pHumanPlayer)
{
	/*if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments != COMMENT_MAIN_WALL)
	{
		pHumanPlayer->vFlagRepair = FALSE;
		pHumanPlayer->vStageRepairWall = 0;
		return FALSE;
	}
	if (pHumanPlayer->vFlagRepair == FALSE &&
		pHumanPlayer->vBase.vSlayerBaze == FALSE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == TRUE &&
		((GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) -
		GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE)) > 100))
	{
		if (pHumanPlayer->vCurrentChain)
		{
			pHumanPlayer->vParamPlayer.vStage = pHumanPlayer->vCurrentChain->vStage;
		}
		pHumanPlayer->vFlagRepair = TRUE;
		pHumanPlayer->vStageRepairWall = 0;
	}
	if (pHumanPlayer->vFlagRepair == TRUE)
	switch(pHumanPlayer->vStageRepairWall)
	{
	case 0:
		if (GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
			(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.8))
		{
			goto m1;
		}
		// Найти позицию для починки вала и забиндить её
		pHumanPlayer->vInt3 = vMapBases.fFindPosRepair(&pHumanPlayer->vBase);
		if (pHumanPlayer->vInt3 != vSizeMap)
		{
			pHumanPlayer->vMainHuman.vPosRepair = pHumanPlayer->vInt3;
			pHumanPlayer->vStageRepairWall++;
		}
		goto m1;
	case 1:
		// Бликнуться к валу
		if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_BLINK) == 1)
			pHumanPlayer->vStageRepairWall++;
		goto m1;
	case 2:
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vActionFinish == 0)
		{
			goto m1;
		}
		// Зафиксировать позицию мове
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->PermissionMove == TRUE)
		{
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->PermissionMove = FALSE;
		}
		pHumanPlayer->vStageRepairWall++;
		goto m1;
	case 3:
		if (GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
			(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.35))
		{
			//vMapBases.fFreePosRepair(&pHumanPlayer->vBase,pHumanPlayer->vInt3);
			pHumanPlayer->vStageRepairWall++;
			goto m1;
		}
		//if (fManaBurnToUnit(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit,vDataUnits[10].pDataUnit) == TRUE) goto m1;
		//if (fManaBurnToUnit(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit,vDataUnits[11].pDataUnit) == TRUE) goto m1;
		// Ремонтировать вал
		if (fRepair(pHumanPlayer,
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit,
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit) == TRUE)
		{
			//if (vMapBases.fFreePosRepair(&pHumanPlayer->vBase,pHumanPlayer->vInt3) == TRUE);
			fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
			pHumanPlayer->vStageRepairWall++;
			goto m1;
		}
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
			(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) -
			GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <= 1))
		{
			fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
			//if (vMapBases.fFreePosRepair(&pHumanPlayer->vBase,pHumanPlayer->vInt3) == TRUE);
			pHumanPlayer->vStageRepairWall++;
			goto m1;
		}
		goto m1;
	case 4:
		// Найти безопасную зону
		pHumanPlayer->vInt3 = vMapBases.fFindPosSafeZone(&pHumanPlayer->vBase);
		if (pHumanPlayer->vInt3 != vSizeMap)
		{
			pHumanPlayer->vStageRepairWall++;
		}
		else
		{
			pHumanPlayer->vStageRepairWall+= 2;
		}
		goto m1;
	case 5:
		// Бликнуться в безопасную зону
		if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vInt3,ACTION_BLINK) == 1)
			pHumanPlayer->vStageRepairWall++;
		goto m1;
	case 6:
		if (vMapBases.fFreePosRepair(&pHumanPlayer->vBase,pHumanPlayer->vMainHuman.vPosRepair) == TRUE);
		pHumanPlayer->vMainHuman.vPosRepair = 0;
		// Расфиксировать позицию мове
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->PermissionMove == FALSE)
		{
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->PermissionMove = TRUE;
		}
		// Обнулить переменные и позицию ремонта вала
		pHumanPlayer->vStageRepairWall = 0;
		pHumanPlayer->vFlagRepair = FALSE;
		return FALSE;
	}
	return FALSE;
m1:*/
	return TRUE;
}

bool fRepair(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, DataUnit *pDataUnit2)
{
	if (pHumanPlayer == NULL || pDataUnit == NULL || pDataUnit2 == NULL) return FALSE;
	//if (vUnit->vIdForComments == COMMENT_NO_UNIT || vUnit2->vIdForComments == COMMENT_NO_UNIT) return FALSE;
		// Смартить вал, если хипов убавилось
		if (pDataUnit->vActionFinish == 1)
		{
			if ((GetUnitState(pDataUnit2->WhichUnit, UNIT_STATE_MAX_LIFE) -
				GetUnitState(pDataUnit2->WhichUnit, UNIT_STATE_LIFE) <= 1))
			{
				pDataUnit->Permission = FALSE;
			}
			if (GetUnitState(pDataUnit2->WhichUnit, UNIT_STATE_MAX_LIFE) -
				GetUnitState(pDataUnit2->WhichUnit, UNIT_STATE_LIFE) > 10)
			{
				pHumanPlayer->vTimeAttackWall = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
				pDataUnit->Permission = TRUE;
				if (IssueTargetOrderById(pDataUnit->WhichUnit,
										 ID_ORDER_SMART,
										 pDataUnit2->WhichUnit) == TRUE)
				{
					goto m1;
				}
			}
			else
			{
				//if (pHumanPlayer->vTimeAttackWall == 0 ||
				//	(pHumanPlayer->vTimeAttackWall != 0 &&
				//	(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeAttackWall > 5)))
				//{
					//// Спустя какое то время. После атаки вампиров.
					goto m2;
				//}
			}
		}
m1:
	return FALSE;
m2:
	return TRUE;
}

bool fCancel_1(HumanPlayer *pHumanPlayer, unsigned short vCommentUnit)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vParamPlayer.vUnit[vCommentUnit].vIdForComments == vCommentUnit &&
		pHumanPlayer->vParamPlayer.vUnit[vCommentUnit].pDataUnit->Upgrade == TRUE &&
		pHumanPlayer->vParamPlayer.vUnit[vCommentUnit].pDataUnit->Postroeno == TRUE)
	{
		if (IssueImmediateOrderById(pHumanPlayer->vParamPlayer.vUnit[vCommentUnit].pDataUnit->WhichUnit,
									ID_ORDER_CANCEL) == TRUE) return TRUE;
	}
	return FALSE;
}

// Побег с базы
bool fEscapeFromTheBase(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vBase.vNBase <= 0) return FALSE;
	/*if (pHumanPlayer->vFlagDearBase == TRUE &&
		pDataHumans->vFlagHelp1 == FALSE &&
		pDataHumans->vFlagHelp2 == FALSE)
	{
		return FALSE;
	}*/
	/*if (pHumanPlayer->vFlagEscapeFromTheBaseTemp == FALSE)
	for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < MAX_VAMPIRE_PLAYERS; pHumanPlayer->vvi++)
	{
		if (vDataUnits[10 + pHumanPlayer->vvi].pDataUnit != NULL &&
			fFindBaseByDataUnit(vDataUnits[10 + pHumanPlayer->vvi].pDataUnit) == pHumanPlayer->vBase.vNBase)
		{
			pHumanPlayer->vFlagEscapeFromTheBaseTemp = TRUE;
			break;
		}
	}*/
	if (pHumanPlayer->vFlagDearBase == TRUE &&
		pHumanPlayer->vFlagEscapeFromTheBaseTemp == FALSE &&
		pHumanPlayer->vFlagEscapeFromTheBase == FALSE)
	if (//pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		//pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_BROWN &&
		((vDataUnits[10 + 0].pDataUnit && fRemotenessBase(vDataUnits[10 + 0].pDataUnit) > 6 &&
		fNBaseUnit(vDataUnits[10 + 0].pDataUnit) == pHumanPlayer->vBase.vNBase &&
		IsUnitVisible(vDataUnits[10 + 0].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE) ||
		(vDataUnits[10 + 1].pDataUnit && fRemotenessBase(vDataUnits[10 + 1].pDataUnit) > 6 &&
		fNBaseUnit(vDataUnits[10 + 1].pDataUnit) == pHumanPlayer->vBase.vNBase &&
		IsUnitVisible(vDataUnits[10 + 1].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE)))
		//((fNBaseUnit(vDataUnits[10 + 0].pDataUnit) == pHumanPlayer->vBase.vNBase &&
		//IsUnitVisible(vDataUnits[10 + 0].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE) ||
		//(fNBaseUnit(vDataUnits[10 + 1].pDataUnit) == pHumanPlayer->vBase.vNBase &&
		//IsUnitVisible(vDataUnits[10 + 1].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE)))// &&
		//pHumanPlayer->vBase.vNBase == pDataHumans->vActionStackForUnitsEnemy.fFindBase())
	{
		pHumanPlayer->vFlagEscapeFromTheBaseTemp = TRUE;
	}
	if (pHumanPlayer->vFlagDearBase == TRUE &&
		pHumanPlayer->vFlagEscapeFromTheBaseTemp == FALSE &&
		pHumanPlayer->vFlagEscapeFromTheBase == FALSE)
	if (pHumanPlayer->vWallCreated == TRUE &&
		pHumanPlayer->vBase.vSlayerBaze == TRUE &&
		(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments != COMMENT_MAIN_WALL ||
		(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == TRUE &&
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.5)))))
	{
		pHumanPlayer->vFlagEscapeFromTheBaseTemp = TRUE;
	}
	/*if (pHumanPlayer->vFlagDearBase == TRUE &&
		pHumanPlayer->vFlagEscapeFromTheBaseTemp == FALSE &&
		pHumanPlayer->vFlagEscapeFromTheBase == FALSE)
	if ((pHumanPlayer->vWallCreated == TRUE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments != COMMENT_MAIN_WALL) ||
		((pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == TRUE &&
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.01)))))// ||
		//(pHumanPlayer->vHelp == TRUE &&
		//vMapBases.fQPosRepair(&pHumanPlayer->vBase) == 0)))
	{
		pHumanPlayer->vFlagEscapeFromTheBaseTemp = TRUE;
	}*/
	if (pHumanPlayer->vFlagDearBase == TRUE &&
		pHumanPlayer->vFlagEscapeFromTheBaseTemp == FALSE &&
		pHumanPlayer->vFlagEscapeFromTheBase == FALSE)
	if (pHumanPlayer->vBase.vSlayerBaze == TRUE &&
		pHumanPlayer->vBase.vHouseForBlockVampire == TRUE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments != COMMENT_MAIN_WALL &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].vIdForComments != COMMENT_HOUSE_FOR_BLOCK_VAMPIRE)
	{
		pHumanPlayer->vFlagEscapeFromTheBaseTemp = TRUE;
	}
	if (pHumanPlayer->vBase.vWallCreated == FALSE)
	{
		if (pDataHumans->vBaseHelp1 == &pHumanPlayer->vBase)
		{
			pDataHumans->vFlagHelp1 = FALSE;
			pDataHumans->vBaseHelp1 = NULL;
		}
		if (pDataHumans->vBaseHelp2 == &pHumanPlayer->vBase)
		{
			pDataHumans->vFlagHelp2 = FALSE;
			pDataHumans->vBaseHelp2 = NULL;
		}
	}
	if (pHumanPlayer->vFlagEscapeFromTheBaseTemp == TRUE)
	{
		pHumanPlayer->vFlagEscapeFromTheBase = TRUE;
		pHumanPlayer->vStageEscapeFromTheBase = 0;
		if (pHumanPlayer->vCurrentChain &&
			pHumanPlayer->vCurrentChain->vAction == CHAIN_ACTION_IMBA_1)
		{
			fCancel_1(pHumanPlayer,COMMENT_FIRE_1);
			fCancel_1(pHumanPlayer,COMMENT_FIRE_2);
			fCancel_1(pHumanPlayer,COMMENT_FIRE_3);
			fCancel_1(pHumanPlayer,COMMENT_FIRE_4);
		}
		//fFreeAllChains(pHumanPlayer);
		fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
		pHumanPlayer->vBlockCreateWorkers = TRUE;
		pHumanPlayer->vHelp = FALSE;
		pHumanPlayer->vFlagDearBase = FALSE;
		//
		pHumanPlayer->vFlagEscapeFromTheBaseTemp = FALSE;
		/*for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < MAX_HUMAN_PLAYERS; pHumanPlayer->vvi++)
		{
			if (pHumanPlayer->vvi != pHumanPlayer->vParamPlayer.vAI &&
				pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBaseNoDear == pHumanPlayer->vBase.vNBase)
			{
				pHumanPlayerGlobal[pHumanPlayer->vvi].vFlagEscapeFromTheBase = TRUE;
				pHumanPlayerGlobal[pHumanPlayer->vvi].vStageEscapeFromTheBase = 6;
			}
		}*/
		pHumanPlayer->vBase.vMainWall = NULL;
		pHumanPlayer->vWallCreated = FALSE;
		pHumanPlayer->vBase.vWallCreated = FALSE;
		for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
		{
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBase != DO_NOT_FIND_BASE &&
				pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBaseNoDear == pHumanPlayer->vBase.vNBase ||
				pHumanPlayerGlobal[pHumanPlayer->vvi].vHelpBase == &pHumanPlayer->vBase)
			{
					pHumanPlayerGlobal[pHumanPlayer->vvi].vFlagEscapeFromTheBase = TRUE;
					pHumanPlayerGlobal[pHumanPlayer->vvi].vStageEscapeFromTheBase = 6;
					//pHumanPlayerGlobal[pHumanPlayer->vvi].vFlagHelp = FALSE;
					//pHumanPlayerGlobal[pHumanPlayer->vvi].vStageHelp = 0;
					fFinishActionUnit(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
			}
		}
		if (fNBaseUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit) != pHumanPlayer->vBase.vNBase)
		{
			pHumanPlayer->vStageEscapeFromTheBase = 3;
			pHumanPlayer->vBase.vDetoWorkers = TRUE;
		}
		pHumanPlayer->vBase.vNBase = DO_NOT_FIND_BASE;
	}
	/*if (pHumanPlayer->vFlagDearBase == FALSE)
	{
		pHumanPlayer->vFlagEscapeFromTheBase = TRUE;
		pHumanPlayer->vStageEscapeFromTheBase = 6;
	}*/
	/*if (pHumanPlayer->vFlagEscapeFromTheBase == FALSE &&
		pHumanPlayer->vBase.vNBase == DO_NOT_FIND_BASE)
	{
		pHumanPlayer->vFlagEscapeFromTheBase = TRUE;
		pHumanPlayer->vStageEscapeFromTheBase = 6;
	}
	if (pHumanPlayer->vFlagEscapeFromTheBase == TRUE &&
		GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit) == 0 &&
		fFindBaseByDataUnitNoEnemy(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit) == 0)
	{
		fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vIdDataUnit);
	}*/
	if (pHumanPlayer->vFlagEscapeFromTheBase == TRUE)
	switch(pHumanPlayer->vStageEscapeFromTheBase)
	{
	case 0:
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].vIdForComments != COMMENT_FOURTH_TENT)
		{
			pHumanPlayer->vStageEscapeFromTheBase += 3;
			goto m1;
		}
		// Найти четвёртый тент
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3 = fConvertXYToI(pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].pDataUnit->vRect1.vX1,
											pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].pDataUnit->vRect1.vY1);
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3 != vSizeMap)
		{
			pHumanPlayer->vStageEscapeFromTheBase++;
		}
		else
		{
			pHumanPlayer->vStageEscapeFromTheBase += 3;
		}
		goto m1;
	case 1:
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].vIdForComments != COMMENT_FOURTH_TENT ||
			GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_MANA) < 4)
		{
			pHumanPlayer->vStageEscapeFromTheBase += 2;
			goto m1;
		}
		fRefreshLastCoordinates(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit);
		pHumanPlayer->vG = fG(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.X,
							  pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.Y,
							  pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].pDataUnit->LastCoordinates.X,
							  pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].pDataUnit->LastCoordinates.Y);
		if (pHumanPlayer->vG > 128 * 2)
		{
			// Бликнуться к первому тенту
			pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit);
			if (pHumanPlayer->vIdOrder != ID_ORDER_BLINK)
			if (fJumpMainHumanToInt(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit,
				                    pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3) == TRUE);
		}
		else
		{
			fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
			pHumanPlayer->vStageEscapeFromTheBase++;
		}
		goto m1;
	case 2:
		// Разрушить четвёртый тент
		if (fAttackAction(pHumanPlayer,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_FOURTH_TENT].vId) == 1)
			pHumanPlayer->vStageEscapeFromTheBase++;
		goto m1;
	case 3:
		// Детонировать всех рабочих
		if (fDetonateAll(pHumanPlayer,ID_UNIT_WORKER,&pHumanPlayer->vActionStackForUnitsWorkers) == TRUE);
		if (pHumanPlayer->vActionStackForUnitsWorkers.fGetQuantityUnits(ID_UNIT_WORKER) == 0)
		{
			pHumanPlayer->vStageEscapeFromTheBase++;
		}
		goto m1;
	case 4:
		if (pHumanPlayer->vBase.vDetoWorkers == TRUE)
		{
			pHumanPlayer->vStageEscapeFromTheBase = 9;
			goto m1;
		}
		// Запомнить время последней атаки
		pHumanPlayer->vTimeLastAttack = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
		pHumanPlayer->vStageEscapeFromTheBase++;
		goto m1;
	case 5:
		// По таймеру рушить тенты в округе
		if (pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeLastAttack > 7 ||
			fIsVampireNearby(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit,pHumanPlayer) == TRUE)
		{
			pHumanPlayer->vStageEscapeFromTheBase++;
			goto m1;
		}
		if (GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
			(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.99))
		{
			pHumanPlayer->vStageEscapeFromTheBase++;
			goto m1;
		}
		pHumanPlayer->hGroupFarm = CreateGroup();
		GroupEnumUnitsInRange(pHumanPlayer->hGroupFarm,
							  pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.X,
							  pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.Y,
							  128*16,Filter(&fFilterBuildFirst));
		pHumanPlayer->u = fGetNearestUnit2(pHumanPlayer->hGroupFarm,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit);
		DestroyGroup(pHumanPlayer->hGroupFarm);
		if (pHumanPlayer->u != 0 &&
			GetOwningPlayer(pHumanPlayer->u) == pHumanPlayer->vParamPlayer.vPlayer)
		{
			pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit);
			pHumanPlayer->vX_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.X;
			pHumanPlayer->vY_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.Y;
			pHumanPlayer->vX_2 = GetUnitX(pHumanPlayer->u);
			pHumanPlayer->vY_2 = GetUnitY(pHumanPlayer->u);
			pHumanPlayer->vG = fG(pHumanPlayer->vX_1,pHumanPlayer->vY_1,pHumanPlayer->vX_2,pHumanPlayer->vY_2);
			if (pHumanPlayer->vG < 128 * 4)
			{
				if (pHumanPlayer->vIdOrder != ID_ORDER_ATTACK &&
					IssueTargetOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit,
										 ID_ORDER_ATTACK,
										 pHumanPlayer->u) == TRUE)
				{
					goto m1;
				}
			}
			else
			{
				if (pHumanPlayer->vIdOrder != ID_ORDER_BLINK &&
					IssueTargetOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit,
										 ID_ORDER_BLINK,
										 pHumanPlayer->u) == TRUE)
				{
					goto m1;
				}
			}
		}
		else
		{
			pHumanPlayer->vStageEscapeFromTheBase++;
		}
		goto m1;
	case 6:
		fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
		// Найти ближайшую базу
		pHumanPlayer->vNBase = fFindNearestBase(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit);
		if (pHumanPlayer->vNBase == DO_NOT_FIND_BASE)
		{
			pHumanPlayer->vBase.vNBase = DO_NOT_FIND_BASE;
			if (fFindIToMapCenter(JASS_DANCEPOOL,&pHumanPlayer->vX_1,&pHumanPlayer->vY_1) == FALSE) return FALSE;
			pHumanPlayer->vX = fConverterX(pHumanPlayer->vX_1);
			pHumanPlayer->vY = fConverterY(pHumanPlayer->vY_1);
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3 = fConvertXYToI(pHumanPlayer->vX,
												pHumanPlayer->vY);
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3 == vSizeMap)
			{
				return FALSE;
			}
			pHumanPlayer->vBase.vNBaseNoDear = pHumanPlayer->vBase.vNBase;
			// Бликнуться к денс пулу
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3,ACTION_BLINK) == 1)
				pHumanPlayer->vStageEscapeFromTheBase = 9;
			goto m1;
		}
		else
		{
			pHumanPlayer->vStageEscapeFromTheBase++;
		}
		goto m1;
	case 7:
		// Найти
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3 = vSizeMap;
		for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
		{
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit != NULL &&
				pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vWallCreated == TRUE &&
				pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBase == pHumanPlayer->vNBase)
			{
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3 = vMapBases.fFindPosSafeZone(&pHumanPlayerGlobal[pHumanPlayer->vvi].vBase);
				break;
			}
		}
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3 != vSizeMap)
		{
			if (pHumanPlayer->vFlagDearBase == FALSE)
			{
				pHumanPlayer->vBase.vNBase = pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBase;
				pHumanPlayer->vBase.vMainWall = pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vMainWall;
				pHumanPlayer->vBase.vNBaseNoDear = pHumanPlayer->vNBase;
			}
			pHumanPlayer->vStageEscapeFromTheBase++;
		}
		else
		{
			pHumanPlayer->vStageEscapeFromTheBase += 2;
		}
		goto m1;
	case 8:
		// Бликнуться
		if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vInt3,ACTION_BLINK) == 1)
			pHumanPlayer->vStageEscapeFromTheBase++;
		goto m1;
	case 9:
		// Завершить побег
		pHumanPlayer->vFlagEscapeFromTheBase = FALSE;
		pHumanPlayer->vStageEscapeFromTheBase = 0;
		return FALSE;
	}
	return FALSE;
m1:
	return TRUE;
}

// Найти ближайшую базу
unsigned short fFindNearestBase(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit)
{
	if (pHumanPlayer == NULL || pDataUnit == NULL) return DO_NOT_FIND_BASE;
	pHumanPlayer->vNBase = DO_NOT_FIND_BASE;
	if (vCountHumans > 0)
	{
		pHumanPlayer->vG2 = 0;
		pHumanPlayer->vX_1 = pDataUnit->LastCoordinates.X;
		pHumanPlayer->vY_1 = pDataUnit->LastCoordinates.Y;
		for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
		{
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit == NULL) continue;
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vWallCreated == FALSE) continue;
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBase == DO_NOT_FIND_BASE) continue;
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vMainWall == NULL) continue;
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBase == pHumanPlayer->vBase.vNBase) continue;
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments != COMMENT_MAIN_WALL) continue;
			pHumanPlayer->vX = fConvertIToX(pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vMainWall->vInt3);
			pHumanPlayer->vY = fConvertIToY(pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vMainWall->vInt3);
			pHumanPlayer->vX_2 = fConverterIX2RX(pHumanPlayer->vX);
			pHumanPlayer->vY_2 = fConverterIY2RY(pHumanPlayer->vY);
			pHumanPlayer->vG = fG(pHumanPlayer->vX_1,pHumanPlayer->vY_1,pHumanPlayer->vX_2,pHumanPlayer->vY_2);
			if (pHumanPlayer->vG2 == 0 || pHumanPlayer->vG2 > pHumanPlayer->vG)
			{
				pHumanPlayer->vNBase = pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBase;
				pHumanPlayer->vG2 = pHumanPlayer->vG;
			}
		}
	}
	return pHumanPlayer->vNBase;
}

// Найти ближайшего юнита в группе
unit fGetNearestUnit2(HGROUP g, DataUnit *pDataUnit)
{
	if (pDataUnit == NULL) return NULL;
	if (g == NULL) return NULL;
	unit u;
	unit u2;
	real vG1;
	real vG2;
	integer vId;
	u2 = 0;
	vG2 = 0;
	do
	{
		u=FirstOfGroup(g);
		if (u != 0)
		{
			if (IsUnitVisible(u,pDataUnit->vPlayer) == TRUE)
			{
				vId = GetUnitTypeId(u);
				
				vG1 = fG(pDataUnit->LastCoordinates.X,
						 pDataUnit->LastCoordinates.Y,
						 GetUnitX(u),
						 GetUnitY(u));
				if (vG2 > vG1 || vG2 == 0)
				{
					u2 = u;
					vG2 = vG1;
				}
			}
		}
		GroupRemoveUnit(g,u);
	}
	while (u != 0);
	if (u2 != 0)
	{
		return u2;
	}
	return 0;
}

// Фильтр первых построек
integer fFilterBuildFirst()
{
	HUNIT u = GetFilterUnit();
	if (u == NULL) return FALSE;
	integer vId;
	vId = GetUnitTypeId(u);
	if (fIsBuildFirst(vId) == TRUE)
	{
		return TRUE;
	}
	return FALSE;
}

bool fJumpSlayerToSlayerPlace(DataUnit * pDataUnit, HPLAYERCOLOR vAI)
{
	if (pDataUnit == NULL) return FALSE;
	real vManaUnit = GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA);
	//integer vIntSlayerPlace = fFindIToMap(JASS_SLAYERPLACE);
	if (vManaUnit >= 500 &&
		!((pDataUnit->LastCoordinates.X > pDataHumans->vCoordinatesSlayerPlace.X - 600) &&
		(pDataUnit->LastCoordinates.X < pDataHumans->vCoordinatesSlayerPlace.X + 600) &&
		(pDataUnit->LastCoordinates.Y > pDataHumans->vCoordinatesSlayerPlace.Y + 300) &&
		(pDataUnit->LastCoordinates.Y < pDataHumans->vCoordinatesSlayerPlace.Y - 300)))
	{
		if (IssuePointOrderById(pDataUnit->WhichUnit,
			ID_ORDER_BLINK_SLAYER,
			pDataHumans->vCoordinatesSlayerPlace.X,
			pDataHumans->vCoordinatesSlayerPlace.Y) == TRUE)
		{
			return TRUE;
		}
	}
	return FALSE;
}

bool fJumpSlayerToManaWell(DataUnit * pDataUnit)
{
	if (pDataUnit == NULL) return FALSE;
	//unit vManaWell = fGetUnit(ID_UNIT_PASSIVE_MANA_KOLODEC,Player(PLAYER_NEUTRAL_PASSIVE));
	//DataUnit *pDataUnit2;
	//pDataUnit2 = fGetDataUnit(vManaWell);
	//if (pDataUnit2)
	if (1)
	{
		real vManaUnit = GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA);
		if (vManaUnit >= 500)
		{
			if (IssuePointOrderById(pDataUnit->WhichUnit,
									ID_ORDER_BLINK_SLAYER,
									pDataHumans->vCoordinatesManaWell.X,
									pDataHumans->vCoordinatesManaWell.Y) == TRUE)
			{
				return TRUE;
			}
		}
	}
	return FALSE;
}

bool fJumpSlayerToInt(DataUnit * pDataUnit, unsigned int vIntIn)
{
	if (pDataUnit == NULL) return FALSE;
	if (vIntIn < 0 || vIntIn >= vSizeMap) return FALSE;
	real vX,vY;
	real vRadius;
	unsigned short vX2, vY2;
	real vManaUnit;
	vManaUnit = GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA);
	vRadius = fRadius_Unit(pDataUnit->vId);
	vX2 = fConvertIToX(vIntIn);
	vY2 = fConvertIToY(vIntIn);
	vX = fGetMinIX2RX(vX2) + vRadius;
	vY = fGetMinIY2RY(vY2) - vRadius;
	if (vManaUnit >= 500)
	{
		if (IssuePointOrderById(pDataUnit->WhichUnit,
								ID_ORDER_BLINK_SLAYER,
								vX,
								vY) == TRUE)
		{
			return TRUE;
		}
	}
	else
	{
		if (IssuePointOrderById(pDataUnit->WhichUnit,
								ID_ORDER_MOVE,
								pDataHumans->vCoordinatesManaWell.X,
								pDataHumans->vCoordinatesManaWell.Y) == TRUE);
	}
	return FALSE;
}

bool fJumpMainHumanToInt(DataUnit * pDataUnit, unsigned int vIntIn)
{
	if (pDataUnit == NULL) return FALSE;
	real vManaUnit = GetUnitState(pDataUnit->WhichUnit, UNIT_STATE_MANA);
	if (vManaUnit >= 1)
	{
		if (vIntIn < 0 || vIntIn >= vSizeMap) return FALSE;
		real vX,vY;
		real vRadius;
		unsigned short vX2, vY2;
		vRadius = fRadius_Unit(pDataUnit->vId);
		vX2 = fConvertIToX(vIntIn);
		vY2 = fConvertIToY(vIntIn);
		vX = fGetMinIX2RX(vX2) + vRadius;
		vY = fGetMinIY2RY(vY2) - vRadius;
		if (IssuePointOrderById(pDataUnit->WhichUnit,
								ID_ORDER_BLINK_SLAYER,
								vX,
								vY) == TRUE)
		{
			return TRUE;
		}
	}
	return FALSE;
}

bool fVampireToManaWell(player vPlayer)
{
	int vvi;
	for (vvi = 0; vvi < MAX_VAMPIRE_PLAYERS; vvi++)
	{
		if (vDataUnits[10 + vvi].pDataUnit)
		{
			if (IsUnitVisible(vDataUnits[10 + vvi].pDataUnit->WhichUnit,vPlayer) == TRUE)
			{
				if (fUnitToRect(vDataUnits[10 + vvi].pDataUnit,vManaWellRect) == TRUE)
				{
					return TRUE;
				}
				//vManaWellRect
			}
		}
	}
	return FALSE;
}

bool fVampiresNoToManaWell(player vPlayer)
{
	int vvi;
	int vQ;
	int vQVampires;
	vQ = 0;
	vQVampires = 0;
	for (vvi = 0; vvi < MAX_VAMPIRE_PLAYERS; vvi++)
	{
		if (vDataUnits[10 + vvi].pDataUnit)
		{
			vQVampires++;
			if (IsUnitVisible(vDataUnits[10 + vvi].pDataUnit->WhichUnit,vPlayer) == TRUE)
			{
				if (fUnitToRect(vDataUnits[10 + vvi].pDataUnit,vManaWellRect) == FALSE)
				{
					vQ++;
				}
			}
		}
	}
	if (vQ == vQVampires)
	{
		return TRUE;
	}
	return FALSE;
}

// Слауер на манавеле
bool fSlayerToManaWell(player vPlayer)
{
	int vvi;
	for (vvi = 12; vvi <  12 + MAX_HUMAN_PLAYERS; vvi++)
	{
		if (vDataUnits[vvi].pDataUnit)
		{
			if (IsUnitVisible(vDataUnits[vvi].pDataUnit->WhichUnit,vPlayer) == TRUE)
			{
				if (fUnitToRect(vDataUnits[vvi].pDataUnit,vManaWellRect) == TRUE)
				{
					return TRUE;
				}
				//vManaWellRect
			}
		}
	}
	return FALSE;
}

// Действия слаера
void fActionsSlayer(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return;
	// Инициализация слаера
	if (fInitSlayer(pHumanPlayer) == FALSE) return;
	// Воскрешение слаера
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->Dead == TRUE)
	{
		if (pHumanPlayer->vTimeResSlayer == 0)
		{
			pHumanPlayer->vTimeResSlayer = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
			pHumanPlayer->vSlayerResurrected = TRUE;
		}
		if (pHumanPlayer->vSlayerResurrected == TRUE &&
			(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeResSlayer > 60))
		{
			if (fResurrectionOfSlayer(pHumanPlayer) == TRUE)
			{
				pHumanPlayer->vSlayerResurrected = FALSE;
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->Dead = FALSE;
				pHumanPlayer->vTimeResSlayer = 0;
			}
		}
		return;
	}
	if (pHumanPlayer->vSlayerResurrected == TRUE) pHumanPlayer->vSlayerResurrected = FALSE;
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit == NULL) return;
	// Прокачать скилы слаеру
	fSkillSlayer(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,0);
	// Сбросить древесину покупающему золото
	if (pHumanPlayer->vParamPlayer.vTimerGetElapsed >= 60 * 12 &&
		pHumanPlayer->vBuyGold == FALSE &&
		pDataHumans->vBuyGold == FALSE &&
		pDataHumans->vBaseHelp1 != NULL &&
		pDataHumans->vBaseHelp2 != NULL &&
		pDataHumans->vBaseHelp1->pHumanPlayer->vStage <= 83 &&
		pDataHumans->vBaseHelp1->pHumanPlayer->vParamPlayer.vUnit[COMMENT_TEMPLE].vIdForComments != COMMENT_TEMPLE &&
		pDataHumans->vFlagHelp1 == TRUE &&
		pDataHumans->vFlagHelp2 == TRUE &&
		pDataHumans->vBaseHelp1 == pDataHumans->vBaseHelp2)
	{
		for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < MAX_HUMAN_PLAYERS; pHumanPlayer->vvi++)
		{
			if (pHumanPlayer->vBase.vSlayerBaze == TRUE &&
				pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer != pHumanPlayer->vParamPlayer.vPlayer)
			{
				if (fTransferRes(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,
								 pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER,
								 GetPlayerState(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER)) == FALSE);
			}
		}
		if (GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER) >= 4000)
		{
			pHumanPlayer->vBuyGold = TRUE;
			pDataHumans->vBuyGold = TRUE;
		}
	}
	// Купить 1 голд за 4 к леса
	if (pHumanPlayer->vBuyGold == TRUE ||
		(pDataHumans->vFirstGold == FALSE &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed >= 60 * 12 &&
		GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_LUMBER) >= 24000))
	{
		if (fBuyGold(pHumanPlayer) == TRUE)
		{
			if (pDataHumans->vFirstGold == FALSE) pDataHumans->vFirstGold = TRUE;
			pHumanPlayer->vBuyGold = FALSE;
			pDataHumans->vBuyGold = FALSE;
		}
	}
	// Если мало хипов у слаера
	if (pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeHPSlayer > 0.8)
	if((GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
	   (GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.7)))
	{
		if (pHumanPlayer->vSlayerDefense == TRUE)
		{
			pHumanPlayer->vSlayerDefense = FALSE;
			vMapBases.fFreePosSlayerDefense(pHumanPlayer->vBaseSlayerDefense,pHumanPlayer);
		}
		pHumanPlayer->vTimeHPSlayer = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
		pHumanPlayer->vFewHPSlayer = TRUE;
		// Прыгнуть слаером на базу
		if (pHumanPlayer->vJumpSlayerToBase == FALSE &&
			//pHumanPlayer->vJumpSlayerToManaWell == FALSE &&
			pDataHumans->vVampireToManaWell == TRUE &&
			pHumanPlayer->vBase.vNBase > 0 &&
			pHumanPlayer->vBase.vNBase != DO_NOT_FIND_BASE &&
			fUnitToRect(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,vBaseVampires) == TRUE &&
			fJumpSlayerToInt(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,vMapBases.fFindPosSafeZone(&pHumanPlayer->vBase)) == TRUE)
		{
			pHumanPlayer->vJumpSlayerToBase = TRUE;
			pHumanPlayer->vJumpSlayerToManaWell = FALSE;
			return;
		}
		// Прыгнуть слаером на манавел
		if (pHumanPlayer->vJumpSlayerToBase == FALSE &&
			//pHumanPlayer->vJumpSlayerToManaWell == FALSE &&
			pDataHumans->vVampireToManaWell == FALSE &&
			fJumpSlayerToManaWell(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit) == TRUE)
		{
			pHumanPlayer->vJumpSlayerToManaWell = TRUE;
			pHumanPlayer->vJumpSlayerToBase = FALSE;
			return;
		}
	}
	else
	{
		pHumanPlayer->vFewHPSlayer = FALSE;
	}
	//
	pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit);
	/*if (pHumanPlayer->vIdOrder == ID_ORDER_ATTACK)
	{
		pHumanPlayer->vTimeManaWell = FALSE;
	}
	else
	{
		//pHumanPlayer->vTimeManaWell = TRUE;
	}*/
	//pHumanPlayer->vVampireToManaWell = TRUE;
	// Проверить видно ли вампиров на манавеле
	if (pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeSlayerOnManaWell >= 1)
	{
		if (fSlayerToManaWell(pHumanPlayer->vParamPlayer.vPlayer) == TRUE)
		{
			pHumanPlayer->vTimeSlayerOnManaWell = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
			if (fVampireToManaWell(pHumanPlayer->vParamPlayer.vPlayer) == TRUE)
			{
				pHumanPlayer->vVampireToManaWell = TRUE;
				pDataHumans->vVampireToManaWell = TRUE;
				pHumanPlayer->vTimeManaWell = FALSE;
			}
			else
			{
				pHumanPlayer->vVampireToManaWell = FALSE;
				pHumanPlayer->vScoutingBySlayer = TRUE;
				pDataHumans->vVampireToManaWell = FALSE;
				if (pHumanPlayer->vIdOrder != ID_ORDER_ATTACK)
				{
					pHumanPlayer->vTimeManaWell = TRUE;
				}
			}
		}
		else if (fVampiresNoToManaWell(pHumanPlayer->vParamPlayer.vPlayer) == TRUE)
		{
			pHumanPlayer->vVampireToManaWell = FALSE;
			pDataHumans->vVampireToManaWell = FALSE;
			if (pHumanPlayer->vIdOrder != ID_ORDER_ATTACK)
			{
				pHumanPlayer->vTimeManaWell = TRUE;
			}
		}
		else
		{
			pHumanPlayer->vScoutingBySlayer = FALSE;
		}
		if (pHumanPlayer->vSlayerDefense == TRUE &&
			pDataHumans->vBaseHelp1 == NULL &&
			pDataHumans->vBaseHelp2 == NULL)
		{
			pHumanPlayer->vSlayerDefense = FALSE;
			vMapBases.fFreePosSlayerDefense(pHumanPlayer->vBaseSlayerDefense,pHumanPlayer);
		}
	}
	else
	{
		pHumanPlayer->vTimeManaWell = FALSE;
	}
	// Если грива есть то слауер дефенс убираем
	if (pDataHumans->vActionStackForUnitsEnemy.fGetQuantityUnits(ID_UNIT_GRIVE) >= 1)
	{
		pHumanPlayer->vSlayerDefense = FALSE;
		vMapBases.fFreePosSlayerDefense(pHumanPlayer->vBaseSlayerDefense,pHumanPlayer);
	}
	// Взять слаером голд коин
	if (pHumanPlayer->vFewHPSlayer == FALSE &&
		pHumanPlayer->vJumpSlayerToSlayerPlace == FALSE &&
		fSlayerGetGoldCoin(pHumanPlayer) == TRUE)
	{
		pHumanPlayer->vGoldCoin = LoadItemHandle(vHT,pHumanPlayer->vParamPlayer.vTimerPlayer,CONST_GOLD_COIN);
		pHumanPlayer->vJumpSlayerToManaWell = FALSE;
		pHumanPlayer->vJumpSlayerToBase = FALSE;
		pHumanPlayer->vScoutingBySlayer = FALSE;
		return;
	}
	else
	{
		pHumanPlayer->vGoldCoin = 0;
	}
	// Не прыгать на слауер плейс
	if ((int)pHumanPlayer->vParamPlayer.vTimerGetElapsed%60 <= 57)
	{
		pHumanPlayer->vJumpSlayerToSlayerPlace = FALSE;
	}
	// Прожать аватар после 12 минуты
	if (pHumanPlayer->vAvatar == FALSE &&
		(int)pHumanPlayer->vParamPlayer.vTimerGetElapsed%60 >= 56 &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed >= (60 * 11 + 55))
	{
		if (IssueImmediateOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,ID_ORDER_AVATAR) == TRUE)
		{
			pHumanPlayer->vAvatar = TRUE;
		}
	}
	// Прыгнуть на слауер плейс
	if (pHumanPlayer->vIdOrder != ID_ORDER_ATTACK &&
		pHumanPlayer->vJumpSlayerToSlayerPlace == FALSE &&
		(int)pHumanPlayer->vParamPlayer.vTimerGetElapsed%60 > 57 &&
		fNBaseUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit) != JASS_SLAYERPLACE &&
		fJumpSlayerToSlayerPlace(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,pHumanPlayer->vParamPlayer.vAI) == TRUE)
	{
		pHumanPlayer->vJumpSlayerToSlayerPlace = TRUE;
		pHumanPlayer->vJumpSlayerToManaWell = FALSE;
		pHumanPlayer->vJumpSlayerToBase = FALSE;
		pHumanPlayer->vScoutingBySlayer = FALSE;
		pHumanPlayer->vAvatar = FALSE;
		return;
	}
	// Защита слаерами у первого попавшегося союзника
	if (pHumanPlayer->vTwoMinutes == TRUE &&
		pHumanPlayer->vFewHPSlayer == FALSE &&
		pHumanPlayer->vSlayerDefense == FALSE)
	{
		pHumanPlayer->vBaseSlayerDefense = fFindBaseSlayerDefense(pHumanPlayer);
		if (pHumanPlayer->vBaseSlayerDefense &&
			pDataHumans->vActionStackForUnitsEnemy.fGetQuantityUnits(ID_UNIT_GRIVE) == 0)
		{
			pHumanPlayer->vMana = GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit, UNIT_STATE_MANA);
			if (pHumanPlayer->vMana >= 1000)
			{
				pHumanPlayer->vPosSlayerDefense = vMapBases.fFindMyPosSlayerDefense(pHumanPlayer->vBaseSlayerDefense,pHumanPlayer);
				if (fJumpSlayerToInt(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,
									 pHumanPlayer->vPosSlayerDefense) == TRUE)
				{
					pHumanPlayer->vRect7.vX1 = fConvertIToX(pHumanPlayer->vPosSlayerDefense);
					pHumanPlayer->vRect7.vY1 = fConvertIToY(pHumanPlayer->vPosSlayerDefense);
					pHumanPlayer->vRect7.vDiff = fRadiusToDiff(fRadius_Unit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->vId));
					pHumanPlayer->vRect7.vX2 = pHumanPlayer->vRect7.vX1 + pHumanPlayer->vRect7.vDiff - 1;
					pHumanPlayer->vRect7.vY2 = pHumanPlayer->vRect7.vY1 + pHumanPlayer->vRect7.vDiff - 1;
					pHumanPlayer->vSlayerDefense = TRUE;
				}
			}
		}
		else
		{
			vMapBases.fFreePosSlayerDefense(pHumanPlayer->vBaseSlayerDefense,pHumanPlayer);
			pHumanPlayer->vBaseSlayerDefense = NULL;
			pHumanPlayer->vSlayerDefense = FALSE;
		}
	}
	// Удерживать позицию пока не мало хипов
	if (pHumanPlayer->vTwoMinutes == TRUE &&
		pHumanPlayer->vFewHPSlayer == FALSE &&
		pHumanPlayer->vSlayerDefense == TRUE)// &&
		//fUnitToRect(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,vManaWellRect) == FALSE)
	{
		pHumanPlayer->vFlag3 = FALSE;
		for (pHumanPlayer->vRect7.vvj2 = pHumanPlayer->vRect7.vY1; pHumanPlayer->vRect7.vvj2 <= pHumanPlayer->vRect7.vY2; pHumanPlayer->vRect7.vvj2++)
		{
			for (pHumanPlayer->vRect7.vvi2 = pHumanPlayer->vRect7.vX1; pHumanPlayer->vRect7.vvi2 <= pHumanPlayer->vRect7.vX2; pHumanPlayer->vRect7.vvi2++)
			{
				pHumanPlayer->pDataUnit = fDataUnitInt3(pHumanPlayer->vPosSlayerDefense,HUMANS);
				if (pHumanPlayer->pDataUnit == pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit)
				{
					pHumanPlayer->vFlag3 = TRUE;
					goto m6;
				}
			}
		}
m6:
		if (pHumanPlayer->vFlag3 == TRUE)
		{
			pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit);
			if (pHumanPlayer->vIdOrder == ID_ORDER_WAITING ||
				pHumanPlayer->vIdOrder == ID_ORDER_HOLDPOSITION)
			{
				if (pHumanPlayer->vBaseSlayerDefense &&
					pHumanPlayer->vBaseSlayerDefense->vNBase == DO_NOT_FIND_BASE)
				{
					pHumanPlayer->vSlayerDefense = FALSE;
					vMapBases.fFreePosSlayerDefense(pHumanPlayer->vBaseSlayerDefense,pHumanPlayer);
				}
				IssueImmediateOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,ID_ORDER_HOLDPOSITION);
				return;
			}
		}
		else if (fJumpSlayerToInt(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,
								  pHumanPlayer->vPosSlayerDefense) == TRUE)
		{
			// прыгаем снова
		}
		else
		{
			vMapBases.fFreePosSlayerDefense(pHumanPlayer->vBaseSlayerDefense,pHumanPlayer);
			pHumanPlayer->vBaseSlayerDefense = NULL;
			pHumanPlayer->vSlayerDefense = FALSE;
		}
	}
	// Убить шамана
	if (pHumanPlayer->vFewHPSlayer == FALSE &&
		pHumanPlayer->vTracker == TRUE &&
		GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit) == 0)
	{
		if (IssueImmediateOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,ID_ORDER_TRACKER) == TRUE)
		{
			//
		}
	}
	// Действия трекера
	if (pHumanPlayer->vTracker == TRUE && pHumanPlayer->vActionStackForUnitsTracker.vQNewUnit > 0)
	{
		pHumanPlayer->pDataUnit = pHumanPlayer->vActionStackForUnitsTracker.fGetDataUnit(COMMENT_NEW_UNIT,ID_UNIT_TRACKER);
		if (pHumanPlayer->pDataUnit)
		{
			if (pDataHumans->vActionStackForUnitsEnemy.fGetQuantityUnits(ID_UNIT_SHAMAN) == 0)
			{
				if (pHumanPlayer->vShaman == TRUE)
				{
					pHumanPlayer->vTracker = FALSE;
				}
				pHumanPlayer->vBaseAnAlly = fBase(pHumanPlayer->pDataUnit,pHumanPlayer);
				if (pHumanPlayer->vBaseAnAlly)
				{
					if (fGoToAction(pHumanPlayer->pDataUnit->vIdDataUnit,vMapBases.fRandPosBase(pHumanPlayer->vBaseAnAlly),ACTION_BLINK) == 1)
					{
						// Прыгаем по базе трекером
					}
				}	
			}
			else
			{
				if (pHumanPlayer->vShaman == FALSE) pHumanPlayer->vShaman = TRUE;
				pHumanPlayer->pDataUnit2 = pDataHumans->vActionStackForUnitsEnemy.fGetDataUnit(COMMENT_NEW_UNIT,ID_UNIT_SHAMAN);
				if (fGoToAction(pHumanPlayer->pDataUnit->vIdDataUnit,fInt3DataUnit(pHumanPlayer->pDataUnit2),ACTION_BLINK) == 1)
				{
					// Прыгаем за шаманом трекером
				}
			}
		}
	}
	// Обнаружить шамана
	if (pHumanPlayer->vFewHPSlayer == FALSE &&
		pHumanPlayer->vTracker == FALSE)
	{
		if (GetHeroLevel(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit) >= 5)
		if (fJumpSlayerToInt(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,
			                 fFindPosShaman(pHumanPlayer)) == TRUE)
		{
			pHumanPlayer->vTracker = TRUE;
			return;
		}
	}
	// Прыгнуть слаером на базу
	if (pHumanPlayer->vFewHPSlayer == TRUE &&
		pDataHumans->vVampireToManaWell == TRUE &&
		pHumanPlayer->vJumpSlayerToBase == FALSE &&
		fUnitToRect(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,vManaWellRect) == TRUE &&
		fJumpSlayerToInt(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,vMapBases.fFindPosSafeZone(&pHumanPlayer->vBase)) == TRUE)
	{
		pHumanPlayer->vJumpSlayerToBase = TRUE;
		pHumanPlayer->vJumpSlayerToManaWell = FALSE;
		pHumanPlayer->vScoutingBySlayer = FALSE;
		return;
	}
	// Две минуты
	if (pHumanPlayer->vTwoMinutes == FALSE &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed >= 60 * 2)
	{
		pHumanPlayer->vTwoMinutes = TRUE;
	}
	if (pHumanPlayer->vTwoMinutes == FALSE) return;
	if (pHumanPlayer->vFewHPSlayer == FALSE)
	{
		pHumanPlayer->vTimeManaWell = FALSE;
	}
	// Побегушки около вампира
	if (pHumanPlayer->vIdOrder != ID_ORDER_ATTACK &&
		pHumanPlayer->vSlayerDefense == FALSE &&
		fSlayerAndVampire(pHumanPlayer) == TRUE)
	{
		goto m5;
	}
	// Прыгнуть слаером на мана вел
	if (pHumanPlayer->vTimeManaWell == TRUE &&
		pDataHumans->vVampireToManaWell == FALSE &&
		pHumanPlayer->vScoutingBySlayer == TRUE &&
		pHumanPlayer->vGoldCoin == 0 &&
		pHumanPlayer->vJumpSlayerToManaWell == FALSE &&
		pHumanPlayer->vJumpSlayerToSlayerPlace == FALSE &&
		(int)pHumanPlayer->vParamPlayer.vTimerGetElapsed%60 < 55 &&
		fUnitToRect(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,vManaWellRect) == FALSE &&
		fJumpSlayerToManaWell(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit) == TRUE)
	{
		pHumanPlayer->vJumpSlayerToManaWell = TRUE;
		pHumanPlayer->vJumpSlayerToBase = FALSE;
		return;
	}
	// Разведать мана вел
	if (pHumanPlayer->vFewHPSlayer == FALSE &&
		//pHumanPlayer->vTimeManaWell == TRUE &&
		pHumanPlayer->vScoutingBySlayer == FALSE &&
		(int)pHumanPlayer->vParamPlayer.vTimerGetElapsed%60 < 55 &&
		fIntelligenceService(pHumanPlayer) == TRUE)
	{
		return;
	}
	// Если хипов хватает, и нет голд коина, то атакуем
	if (pHumanPlayer->vFewHPSlayer == FALSE && pHumanPlayer->vGoldCoin == 0)
	{
		// Атакавать шамана
		if (fAttackSlayer(pHumanPlayer,ID_UNIT_SHAMAN,0) == TRUE) goto m5;
		// Атакавать гриву
		if (fAttackSlayer(pHumanPlayer,ID_UNIT_GRIVE,0) == TRUE) goto m5;
		// Атакавать инфернала
		if (fAttackSlayer(pHumanPlayer,ID_UNIT_INFERNAL,0) == TRUE) goto m5;
		// Атакавать файр инфернала
		if (fAttackSlayer(pHumanPlayer,ID_UNIT_FIRE_INFERNAL,0) == TRUE) goto m5;
		// Атакавать тиника
		if (fAttackSlayer(pHumanPlayer,ID_UNIT_TINI,0) == TRUE) goto m5;
		// Атакавать Вампира 1
		if (fAttackSlayer(pHumanPlayer,ID_UNIT_VAMPIRE1,0) == TRUE) goto m5;
		// Атакавать Вампира 2
		if (fAttackSlayer(pHumanPlayer,ID_UNIT_VAMPIRE2,0) == TRUE) goto m5;
		// Атакавать Вампира 3
		if (fAttackSlayer(pHumanPlayer,ID_UNIT_VAMPIRE3,0) == TRUE) goto m5;
		// Атакавать черные здания
		if (fAttackSlayer(pHumanPlayer,0,1) == TRUE) goto m5;
	}
	pHumanPlayer->vManaUnit = GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit, UNIT_STATE_MANA);
	pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit);
	if (pDataHumans->vVampireToManaWell == FALSE &&
		pHumanPlayer->vJumpSlayerToSlayerPlace == FALSE &&
		pHumanPlayer->vBaseSlayerDefense == NULL &&
		pHumanPlayer->vManaUnit < 500 &&
		pHumanPlayer->vIdOrder != ID_ORDER_MOVE &&
		fJumpSlayerToInt(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,
			             vSizeMap/2) == TRUE)
	{
		goto m5;
	}
	if (pDataHumans->vVampireToManaWell == TRUE &&
		pHumanPlayer->vJumpSlayerToSlayerPlace == FALSE &&
		pHumanPlayer->vBaseSlayerDefense == NULL &&
		pHumanPlayer->vManaUnit < 500 &&
		pHumanPlayer->vIdOrder != ID_ORDER_MOVE &&
		fJumpSlayerToInt(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,
			             fJumpBack(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit)) == TRUE)
	{
		goto m5;
	}
	return;
m5:
	pHumanPlayer->vJumpSlayerToManaWell = FALSE;
}

bool fSlayerAndVampire(HumanPlayer * pHumanPlayer)
{
	pHumanPlayer->vManaUnit = GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit, UNIT_STATE_MANA);
	pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit);
	if (pHumanPlayer->vIdOrder != ID_ORDER_MOVE && pHumanPlayer->vIdOrder != ID_ORDER_WAITING) return FALSE;
	if (vMapBases.fRemotenessBase(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.X,
								  pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.Y) <= 0 &&
		(vDataUnits[10 + 0].pDataUnit == NULL || (vDataUnits[10 + 0].pDataUnit &&
			IsUnitVisible(vDataUnits[10 + 0].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
			fG(vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X,
			vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y,
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.X,
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.Y) < (128 * 6))) &&
			(vDataUnits[10 + 1].pDataUnit == NULL || (vDataUnits[10 + 1].pDataUnit &&
			IsUnitVisible(vDataUnits[10 + 1].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
			fG(vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X,
			vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y,
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.X,
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.Y) < (128 * 6))))
	{
		pHumanPlayer->vX_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.X;
		pHumanPlayer->vY_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.Y;
		pHumanPlayer->vG = 0;
		pHumanPlayer->vG2 = 0;
		if (vDataUnits[10 + 0].pDataUnit)
		{
			pHumanPlayer->vG = fG(vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X,
									vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y,
									pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.X,
									pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.Y);
		}
		if (vDataUnits[10 + 1].pDataUnit)
		{
			pHumanPlayer->vG2 = fG(vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X,
									vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y,
									pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.X,
									pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.Y);
		}
		if (vDataUnits[10 + 0].pDataUnit &&
			pHumanPlayer->vG < pHumanPlayer->vG2)
		{
			pHumanPlayer->vX_2 = vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X;
			pHumanPlayer->vY_2 = vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y;
												
		}
		else if (vDataUnits[10 + 1].pDataUnit &&
			pHumanPlayer->vG >= pHumanPlayer->vG2)
		{
			pHumanPlayer->vX_2 = vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X;
			pHumanPlayer->vY_2 = vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y;
		}
		if (pHumanPlayer->vG != 0 && pHumanPlayer->vG <= 128 * 3 || pHumanPlayer->vG2 != 0 && pHumanPlayer->vG2 <= 128 * 3)
		{
			pHumanPlayer->vX_1 = GetRandomInt(-1000,1000);
			pHumanPlayer->vY_1 = GetRandomInt(-1000,1000);
			IssuePointOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
						"blink",
						pHumanPlayer->vX_1,
						pHumanPlayer->vY_1);
		}
		else if (pHumanPlayer->vG != 0 && pHumanPlayer->vG < 128 * 4 || pHumanPlayer->vG2 != 0 && pHumanPlayer->vG2 < 128 * 4)
		{
			pHumanPlayer->vX_1 = 0;
			pHumanPlayer->vY_1 = 256;
		}
		else
		{
			pHumanPlayer->vX_1 = pHumanPlayer->vX_1 + abs(pHumanPlayer->vX_2 - pHumanPlayer->vX_1) / 6 *
				(pHumanPlayer->vX_1 >= pHumanPlayer->vX_2 ? 1 : -1);
			pHumanPlayer->vY_1 = pHumanPlayer->vY_1 + abs(pHumanPlayer->vY_2 - pHumanPlayer->vY_1) / 6 *
				(pHumanPlayer->vY_1 >= pHumanPlayer->vY_2 ? -1 : 1);
		}
		if (pHumanPlayer->vManaUnit >= 1500 &&
			abs(pHumanPlayer->vG2 - pHumanPlayer->vG) < 1000 &&
			(pHumanPlayer->vG2 > 2000 || pHumanPlayer->vG > 2000))
		{
			IssuePointOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
						"blink",
						pHumanPlayer->vX_1,
						pHumanPlayer->vY_1);
		}
		else
		{
			IssuePointOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
						"move",
						pHumanPlayer->vX_1,
						pHumanPlayer->vY_1);
		}
		return TRUE;
	}
	else if (pHumanPlayer->vManaUnit >= 500 && fUnitToRect(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,vManaWellRect) == TRUE)
	{
		pHumanPlayer->vX_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.X;
		pHumanPlayer->vY_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.Y;
		pHumanPlayer->vG = 0;
		pHumanPlayer->vG2 = 0;
		if (vDataUnits[10 + 0].pDataUnit &&
			IsUnitVisible(vDataUnits[10 + 0].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE)
		{
			pHumanPlayer->vG = fG(vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X,
									vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y,
									pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.X,
									pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.Y);
		}
		if (vDataUnits[10 + 1].pDataUnit &&
			IsUnitVisible(vDataUnits[10 + 1].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE)
		{
			pHumanPlayer->vG2 = fG(vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X,
									vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y,
									pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.X,
									pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.Y);
		}
		if (vDataUnits[10 + 0].pDataUnit &&
			IsUnitVisible(vDataUnits[10 + 0].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
			pHumanPlayer->vG < pHumanPlayer->vG2)
		{
			pHumanPlayer->vX_2 = vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X;
			pHumanPlayer->vY_2 = vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y;
												
		}
		else if (vDataUnits[10 + 1].pDataUnit &&
			IsUnitVisible(vDataUnits[10 + 1].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
			pHumanPlayer->vG >= pHumanPlayer->vG2)
		{
			pHumanPlayer->vX_2 = vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X;
			pHumanPlayer->vY_2 = vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y;
		}
		else if (vDataUnits[10 + 0].pDataUnit)
		{
			pHumanPlayer->vX_2 = vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X;
			pHumanPlayer->vY_2 = vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y;
		}
		else if (vDataUnits[10 + 1].pDataUnit)
		{
			pHumanPlayer->vX_2 = vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X;
			pHumanPlayer->vY_2 = vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y;
		}
		IssuePointOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
						"move",
						pHumanPlayer->vX_2,
						pHumanPlayer->vY_2);
		//return TRUE;
	}
	return FALSE;
}

bool fSlayerGetGoldCoin(HumanPlayer * pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit == NULL) return FALSE;
	pHumanPlayer->vItem = 0;
	if (IsItemVisible(pHumanPlayer->vGoldCoin) == FALSE)
	{
		SaveInteger(vHT,pHumanPlayer->vParamPlayer.vTimerPlayer,CONST_FLAG_FOR_GOLD_COIN,1);
		SavePlayerHandle(vHT,pHumanPlayer->vParamPlayer.vTimerPlayer,CONST_PLAYER_FOR_GOLD_COIN,pHumanPlayer->vParamPlayer.vPlayer);
		SaveInteger(vHT,pHumanPlayer->vParamPlayer.vTimerPlayer,CONST_ID_UNIT_FOR_GOLD_COIN,pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->vId);
		SaveItemHandle(vHT,pHumanPlayer->vParamPlayer.vTimerPlayer,CONST_GOLD_COIN,0);
		EnumItemsInRect(vWorldRect, NULL, &fActionItemsGold);
		pHumanPlayer->vItem = LoadItemHandle(vHT,pHumanPlayer->vParamPlayer.vTimerPlayer,CONST_GOLD_COIN);
	}
	else
	{
		if (pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeItemGold < 2)
		{
			return FALSE;
		}
		pHumanPlayer->vItem = pHumanPlayer->vGoldCoin;
	}	
	
	if (pHumanPlayer->vItem != 0)
	{
		pHumanPlayer->vX_1 = GetUnitX(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit);
		pHumanPlayer->vY_1 = GetUnitY(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit);
		pHumanPlayer->vX_2 = GetItemX(pHumanPlayer->vItem);
		pHumanPlayer->vY_2 = GetItemY(pHumanPlayer->vItem);
		pHumanPlayer->vG = fG(pHumanPlayer->vX_1,pHumanPlayer->vY_1,pHumanPlayer->vX_2,pHumanPlayer->vY_2);// = sqrtf(powf(abs(vX_1 - vX_2),2)+powf(abs(vY_1 - vY_2),2));
		if (pHumanPlayer->vG > 128)
		{
			pHumanPlayer->vManaUnit = GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit, UNIT_STATE_MANA);
			if (pHumanPlayer->vManaUnit >= 1000)
			{
				if (IssueTargetOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
										 ID_ORDER_BLINK_SLAYER,
										 pHumanPlayer->vItem) == TRUE)
				{
					pHumanPlayer->vTimeItemGold = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
					return TRUE;
				}
			}
		}
		else
		{
			if (IssueTargetOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
									 ID_ORDER_SMART,
									 pHumanPlayer->vItem) == TRUE)
			{
				pHumanPlayer->vTimeItemGold = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
				return TRUE;
			}
		}
	}
	return FALSE;
}

void fSkillSlayer(DataUnit *pDataUnit, integer vFlag)
{
	if (pDataUnit == NULL) return;
	if (pDataUnit->Lvl == FALSE) return;
	integer vSkillPoints = GetHeroSkillPoints(pDataUnit->WhichUnit);
	integer vLevel = GetHeroLevel(pDataUnit->WhichUnit);
	integer vIdSkill;
	int vvi;
	vIdSkill = 0;
	for (vvi = 0; vvi < vSkillPoints; vvi++)
	{
		switch(vLevel)
		{
		case 5:
			vIdSkill = ID_SKILL_TRACKER;//AbilityId("");
			break;
		case 10:
			vIdSkill = ID_SKILL_AVATAR;
			break;
		case 11:
		case 20:
			vIdSkill = ID_SKILL_IMMORTALITY_BUILD;
			break;
		case 15:
			vIdSkill = ID_SKILL_ENSNARE;
			break;
		default:
			vIdSkill = ID_SKILL_STATS;
			break;
		}
		SelectHeroSkill(pDataUnit->WhichUnit,vIdSkill);
		pDataUnit->Lvl = FALSE;
	}
}

// Инициализация слаера
bool fInitSlayer(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	/*if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].vIdForComments == COMMENT_SLAYER &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->Dead == TRUE &&
		(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeResSlayer > 60))
	{
		//pHumanPlayer->vSlayerInit = FALSE;
		fAddDataUnitInRange(pHumanPlayer,pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit);
	}*/
	if (pHumanPlayer->vSlayerInit == TRUE) return TRUE;
	if (pHumanPlayer->vActionStackForUnitsSlayer.fGetQuantityUnits(ID_UNIT_SLAYER1) >= 1)
	{
		if (pHumanPlayer->vActionStackForUnitsSlayer.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_SLAYER1,COMMENT_SLAYER) == true)
		{
			pHumanPlayer->vInventorySlayer.fInit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit);
			pHumanPlayer->vInventorySlayer.fRefreshInventory();
			pHumanPlayer->vSlayerInit = TRUE;
			return TRUE;
		}
	}
	return FALSE;
}

// Воскрешение слаера
bool fResurrectionOfSlayer(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].vIdForComments == COMMENT_TAVERN_SLAYER)
	{
		if (ReviveHero(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
					   pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->LastCoordinates.X,
					   pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->LastCoordinates.Y,
					   TRUE) == TRUE)
			return TRUE;
		/*HUNIT vMassHero[1];
		vMassHero[0] = pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit;
		if (IssueImmediateOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->WhichUnit,
									(integer)vMassHero[0]) == TRUE)
		{
			return TRUE;
		}*/
		/*if (IssueNeutralImmediateOrderById(pHumanPlayer->vParamPlayer.vPlayer,
										   pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->WhichUnit,
										   pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit) == TRUE)
		{
			return TRUE;
		}
		if (IssueNeutralImmediateOrderById(pHumanPlayer->vParamPlayer.vPlayer,
										   pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->WhichUnit,
										   (integer)pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit) == TRUE)
		{
			return TRUE;
		}
		bool vJump;
		vJump = FALSE;
		if (vJump == TRUE) goto m44;
		if (IssueNeutralImmediateOrderById(pHumanPlayer->vParamPlayer.vPlayer,
										   pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->WhichUnit,
										   851978) == TRUE)
		{
			return TRUE;
		}
m44:
		if (IssueImmediateOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->WhichUnit,
									851978) == TRUE)
		{
			return TRUE;
		}*//*
		for (int vvi = 0; vvi <= 999999; vvi++)
		{
			if (vvi != ID_ORDER_STOP &&
				vvi != ID_ORDER_HOLDPOSITION &&
				vvi != ID_ORDER_PATROL &&
				vvi != ID_ORDER_ATTACK &&
				vvi != ID_ORDER_SMART &&
				vvi != ID_ORDER_MOVE &&
				vvi != ID_ORDER_CANCEL)// &&
				//vvi != 851978)// &&
				//vvi != 851980 &&
				//vvi != 851973)
			if (IssueNeutralImmediateOrderById(pHumanPlayer->vParamPlayer.vPlayer,
											   pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->WhichUnit,
											   vvi) == TRUE)
			{
				return TRUE;
			}
		}*/
		/*
		if (IssueImmediateOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->WhichUnit,
									pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit) == TRUE)
		{
			return TRUE;
		}
		if (IssueImmediateOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->WhichUnit,
									ID_UNIT_SLAYER1) == TRUE)
		{
			return TRUE;
		}*/
		/*if (IssueImmediateOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER].pDataUnit->WhichUnit,
									ID_ORDER_RES_HERO) == TRUE)
		{
			return TRUE;
		}*/
		/*if (fTrainAction(pHumanPlayer->vParamPlayer.vPlayer,&pHumanPlayer->vParamPlayer.vUnit[COMMENT_TAVERN_SLAYER],ID_UNIT_SLAYER1,1) == 1)
		{
			return TRUE;
		}*/
	}
	return FALSE;
}

// Разведка слаером мана вела
bool fIntelligenceService(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	pHumanPlayer->vManaUnit = GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit, UNIT_STATE_MANA);
	pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit);
	if (pHumanPlayer->vIdOrder != ID_ORDER_WAITING) return FALSE;

	pHumanPlayer->pDataUnit = vDataUnits[vManaWell].pDataUnit;
	if (fUnitToRect(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,vBaseVampires) == TRUE)
	{
		pHumanPlayer->vX_1 = pHumanPlayer->pDataUnit->LastCoordinates.X;
		pHumanPlayer->vY_1 = pHumanPlayer->pDataUnit->LastCoordinates.Y;
		if (IssuePointOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
								ID_ORDER_MOVE,
								pHumanPlayer->vX_1,
								pHumanPlayer->vY_1) == TRUE) return TRUE;
	}
	if (pHumanPlayer->vManaUnit < 1500) return FALSE;
	int vvi;
	double vStepRad;
	unsigned short vR;
	vR = 14;

	vStepRad = vPI / (vR);

	vvi = 28 + GetRandomInt(0,14);//rand()%(14+1);
	if (vvi >= 28 && vvi <= 42)
	{
		pHumanPlayer->vX_2 = cos(vvi*vStepRad) * (vR) * 128;
		pHumanPlayer->vY_2 = sin(vvi*vStepRad) * (vR) * -128;
		pHumanPlayer->vX_1 = pHumanPlayer->pDataUnit->LastCoordinates.X + pHumanPlayer->vX_2;
		pHumanPlayer->vY_1 = pHumanPlayer->pDataUnit->LastCoordinates.Y + pHumanPlayer->vY_2;
		if (IssuePointOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
								ID_ORDER_BLINK_SLAYER,
								pHumanPlayer->vX_1,
								pHumanPlayer->vY_1) == TRUE) return FALSE;
	}
	return FALSE;
}

// Купить голд на базе вамов
bool fBuyGold(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit);
	if (pHumanPlayer->vIdOrder != ID_ORDER_WAITING) return FALSE;

	pHumanPlayer->pDataUnit = vDataUnits[vSven].pDataUnit;
	if (fUnitToRect(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit,vBaseVampires) != TRUE)
	{
		pHumanPlayer->vX_1 = pHumanPlayer->pDataUnit->LastCoordinates.X;
		pHumanPlayer->vY_1 = pHumanPlayer->pDataUnit->LastCoordinates.Y;
		if (IssuePointOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
								ID_ORDER_BLINK_SLAYER,
								pHumanPlayer->vX_1,
								pHumanPlayer->vY_1) == TRUE) return FALSE;
	}
	else
	{
		
		if (pHumanPlayer->vInventorySlayer.vQFreeSlots() > 0 &&
			fBuyItem(vSven,ID_ITEM_4000_WOOD_1_GOLD,&pHumanPlayer->vInventorySlayer) == TRUE)
		{
			return TRUE;
		}
	}
	return FALSE;
}

// Атакавать слаером
bool fAttackSlayer(HumanPlayer * pHumanPlayer, integer vId, integer vFlagEnemy2)
{
	if (pHumanPlayer == NULL) return FALSE;
	pHumanPlayer->vManaUnit = GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit, UNIT_STATE_MANA);
	pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit);
	pHumanPlayer->pDataUnit = fGetDataUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->TargetUnit);
	pHumanPlayer->vId = 0;
	if (pHumanPlayer->pDataUnit == NULL)
	{
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->TargetUnit = NULL;
	}
	else
	{
		pHumanPlayer->vId = GetUnitTypeId(pHumanPlayer->pDataUnit->WhichUnit);
	}
	if ((pHumanPlayer->vId == vId && fIsVampire(vId) == FALSE) &&
		pHumanPlayer->vIdOrder == ID_ORDER_ATTACK) return TRUE;
	if ((vFlagEnemy2 == 0 && pDataHumans->vActionStackForUnitsEnemy.fGetQuantityUnits(vId) >= 1) ||
		(vFlagEnemy2 == 1 && pDataHumans->vActionStackForUnitsEnemy2.fIsUnit() == TRUE))
	{
		pHumanPlayer->pDataUnit = NULL;
		if (vFlagEnemy2 == 0)
		{
			if (fIsVampire(vId) == FALSE)
			{
				// Бьем не вампиров
				pHumanPlayer->pDataUnit = pDataHumans->vActionStackForUnitsEnemy.fGetDataUnit(COMMENT_NEW_UNIT,vId);
			}
			else
			{
				// Бьем вампиров
				pHumanPlayer->pDataUnit2 = NULL;
				if (vDataUnits[10].pDataUnit)
					pHumanPlayer->pDataUnit2 = fGetDataUnit(vDataUnits[10].pDataUnit->TargetUnit);
				if (vDataUnits[10].pDataUnit &&
					(GetUnitState(vDataUnits[10].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
					(GetUnitState(vDataUnits[10].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.35) ||
					GetUnitState(vDataUnits[10].pDataUnit->WhichUnit, UNIT_STATE_MANA) < 500) &&
					fUnitToRect(vDataUnits[10].pDataUnit,vManaWellRect) == FALSE ||
					 (pHumanPlayer->vParamPlayer.vTimerGetElapsed < 60 * 12 &&
					 pHumanPlayer->pDataUnit2 != NULL &&
					 (fIsWall(pHumanPlayer->pDataUnit2->vId) == TRUE ||
					 fIsMainHuman(pHumanPlayer->pDataUnit2->vId) == TRUE) &&
					 pHumanPlayer->pDataUnit2->vId != ID_UNIT_BUILD_WALL_BROWN
					 ))
				{
					pHumanPlayer->pDataUnit = vDataUnits[10].pDataUnit;
					goto m20;
				}
				pHumanPlayer->pDataUnit2 = NULL;
				if (vDataUnits[11].pDataUnit)
					pHumanPlayer->pDataUnit2 = fGetDataUnit(vDataUnits[11].pDataUnit->TargetUnit);
				if (vDataUnits[11].pDataUnit &&
					(GetUnitState(vDataUnits[11].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
					(GetUnitState(vDataUnits[11].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.35) ||
					GetUnitState(vDataUnits[11].pDataUnit->WhichUnit, UNIT_STATE_MANA) < 500) &&
					fUnitToRect(vDataUnits[11].pDataUnit,vManaWellRect) == FALSE ||
					 (pHumanPlayer->vParamPlayer.vTimerGetElapsed < 60 * 12 &&
					 pHumanPlayer->pDataUnit2 != NULL && 
					 (fIsWall(pHumanPlayer->pDataUnit2->vId) == TRUE ||
					 fIsMainHuman(pHumanPlayer->pDataUnit2->vId) == TRUE) &&
					 pHumanPlayer->pDataUnit2->vId != ID_UNIT_BUILD_WALL_BROWN
					 ))
				{
					pHumanPlayer->pDataUnit = vDataUnits[11].pDataUnit;
					goto m20;
				}
				return FALSE;
			}
		}
		else if (vFlagEnemy2 == 1)
		{
			// Бьем черные здания
			pHumanPlayer->pDataUnit = pDataHumans->vActionStackForUnitsEnemy2.fGetFirstUnit();
		}
m20:
		if (pHumanPlayer->pDataUnit == NULL) return FALSE;
		pHumanPlayer->vX_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.X;
		pHumanPlayer->vY_1 = pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->LastCoordinates.Y;
		if (vFlagEnemy2 == 0)
		{
			pHumanPlayer->vX_2 = pHumanPlayer->pDataUnit->LastCoordinatesForEnemy.X;
			pHumanPlayer->vY_2 = pHumanPlayer->pDataUnit->LastCoordinatesForEnemy.Y;
		}
		else if (vFlagEnemy2 == 1)
		{
			pHumanPlayer->vX_2 = pHumanPlayer->pDataUnit->LastCoordinates.X;
			pHumanPlayer->vY_2 = pHumanPlayer->pDataUnit->LastCoordinates.Y;
		}
		pHumanPlayer->vG = fG(pHumanPlayer->vX_1,pHumanPlayer->vY_1,pHumanPlayer->vX_2,pHumanPlayer->vY_2);
		if ((pHumanPlayer->vG < 128*2 && fIsVampire(vId) == FALSE) ||
			(pHumanPlayer->vG < 2500 && fIsVampire(vId) == TRUE))//вблизи бьем
		{
			if (vId == ID_UNIT_SHAMAN || vId == ID_UNIT_SHADOW || vFlagEnemy2 == 1) goto m10; 
			if (pHumanPlayer->vManaUnit < 500) return FALSE;
			if (pHumanPlayer->vParamPlayer.vTimerGetElapsed > (60 * 11) &&
				fIsVampire(vId) == FALSE &&
				vId != ID_UNIT_GRIVE &&
				vId != ID_UNIT_FIRE_INFERNAL)
			if (vDataUnits[10].pDataUnit)
			{
				pHumanPlayer->vX_2 = vDataUnits[10].pDataUnit->LastCoordinatesForEnemy.X;
				pHumanPlayer->vY_2 = vDataUnits[10].pDataUnit->LastCoordinatesForEnemy.Y;
				pHumanPlayer->vG = fG(pHumanPlayer->vX_1,pHumanPlayer->vY_1,pHumanPlayer->vX_2,pHumanPlayer->vY_2);
				if (pHumanPlayer->vG < 128 * 3) return FALSE;
			}
			if (pHumanPlayer->vParamPlayer.vTimerGetElapsed > (60 * 11) &&
				fIsVampire(vId) == FALSE &&
				vId != ID_UNIT_GRIVE &&
				vId != ID_UNIT_FIRE_INFERNAL)
			if (vDataUnits[11].pDataUnit)
			{
				pHumanPlayer->vX_2 = vDataUnits[11].pDataUnit->LastCoordinatesForEnemy.X;
				pHumanPlayer->vY_2 = vDataUnits[11].pDataUnit->LastCoordinatesForEnemy.Y;
				pHumanPlayer->vG = fG(pHumanPlayer->vX_1,pHumanPlayer->vY_1,pHumanPlayer->vX_2,pHumanPlayer->vY_2);
				if (pHumanPlayer->vG < 128 * 3) return FALSE;
			}
			if (IsUnitVisible(pHumanPlayer->pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer))
m10:
			if ((unsigned int)pHumanPlayer->pDataUnit->WhichUnit != 0xdddddddd &&
				(unsigned int)pHumanPlayer->pDataUnit->WhichUnit != 0xcdcdcdcd &&
				(unsigned int)pHumanPlayer->pDataUnit->WhichUnit != 0xcccccccc)
			if (IssueTargetOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
									 ID_ORDER_ATTACK,
									 pHumanPlayer->pDataUnit->WhichUnit) == TRUE)
			{
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->TargetUnit = pHumanPlayer->pDataUnit->WhichUnit;
				return TRUE;
			}
		}
		else//вдали прыгаем
		{
			if (vId == ID_UNIT_SHAMAN || vId == ID_UNIT_SHADOW || vFlagEnemy2 == 1) goto m11; 
			if (pHumanPlayer->vManaUnit < 1000) return FALSE;
			pHumanPlayer->vX_1 = pHumanPlayer->pDataUnit->LastCoordinatesForEnemy.X;
			pHumanPlayer->vY_1 = pHumanPlayer->pDataUnit->LastCoordinatesForEnemy.Y;
			if (pHumanPlayer->vParamPlayer.vTimerGetElapsed > (60 * 11) &&
				fIsVampire(vId) == FALSE &&
				vId != ID_UNIT_GRIVE &&
				vId != ID_UNIT_FIRE_INFERNAL)
			if (vDataUnits[10].pDataUnit)
			{
				pHumanPlayer->vX_2 = vDataUnits[10].pDataUnit->LastCoordinatesForEnemy.X;
				pHumanPlayer->vY_2 = vDataUnits[10].pDataUnit->LastCoordinatesForEnemy.Y;
				pHumanPlayer->vG = fG(pHumanPlayer->vX_1,pHumanPlayer->vY_1,pHumanPlayer->vX_2,pHumanPlayer->vY_2);
				if (pHumanPlayer->vG < 128 * 5) return FALSE;
			}
			if (pHumanPlayer->vParamPlayer.vTimerGetElapsed > (60 * 11) &&
				fIsVampire(vId) == FALSE &&
				vId != ID_UNIT_GRIVE &&
				vId != ID_UNIT_FIRE_INFERNAL)
			if (vDataUnits[11].pDataUnit)
			{
				pHumanPlayer->vX_2 = vDataUnits[11].pDataUnit->LastCoordinatesForEnemy.X;
				pHumanPlayer->vY_2 = vDataUnits[11].pDataUnit->LastCoordinatesForEnemy.Y;
				pHumanPlayer->vG = fG(pHumanPlayer->vX_1,pHumanPlayer->vY_1,pHumanPlayer->vX_2,pHumanPlayer->vY_2);
				if (pHumanPlayer->vG < 128 * 5) return FALSE;
			}
			if (IsUnitVisible(pHumanPlayer->pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer))
m11:
			if (pHumanPlayer->vIdOrder != ID_ORDER_BLINK_SLAYER &&
				(unsigned int)pHumanPlayer->pDataUnit->WhichUnit != 0xdddddddd &&
				(unsigned int)pHumanPlayer->pDataUnit->WhichUnit != 0xcdcdcdcd &&
				(unsigned int)pHumanPlayer->pDataUnit->WhichUnit != 0xcccccccc)
			if (IssueTargetOrderById(pHumanPlayer->vParamPlayer.vUnit[COMMENT_SLAYER].pDataUnit->WhichUnit,
									 ID_ORDER_BLINK_SLAYER,
									 pHumanPlayer->pDataUnit->WhichUnit) == TRUE)
			{
				return TRUE;
			}
		}
	}
	return FALSE;
}

unsigned short fBuildAction(HumanPlayer * pHumanPlayer, unsigned short vIdDataUnit, integer vInt, integer vIdDataUnitBuild)
{
	if (pHumanPlayer == NULL) return FALSE;
	/*if (pHumanPlayer->vTimeBuild != 0 &&
		pHumanPlayer->vParamPlayer.vStage != 80 &&
		(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeBuild > 15))
	{
		pHumanPlayer->vTimeBuild = 0;
		fFinishActionUnit(vIdDataUnit);
		pHumanPlayer->vParamPlayer.vStage--;
		return 0;
	}*/
	if (fGetActionUnit(vIdDataUnit) == ACTION_WAITING && fGetActionUnitFinish(vIdDataUnit) == 1)
	{
		if (fIsEnoughResourses(pHumanPlayer->vParamPlayer.vPlayer,vIdDataUnitBuild) == FALSE) return 2;
		fFreeActionUnit(vIdDataUnit);
		if (fBuild(vIdDataUnit,vInt,vIdDataUnitBuild) == 1)
		{
			//pHumanPlayer->vTimeBuild = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
			return 1;
		}
		else
		{
			fFinishActionUnit(vIdDataUnit);
		}
	}
	return 0;
}

void fPreActionsHuman(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return;
	// Рушим домик 1
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].vIdForComments == COMMENT_HOUSE_FOR_BLOCK_VAMPIRE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].pDataUnit->vId == ID_UNIT_BUILD_DOM &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed > 2 * 60)
	{
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vIdForComments == COMMENT_TOWER_FOR_BLOCK_SHADE_1 &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].pDataUnit->Postroeno == TRUE)
		{
			if (fAttackAction(pHumanPlayer,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vId,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].vId) == 0)
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vId);
			}
		}
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vIdForComments == COMMENT_TOWER_FOR_BLOCK_SHADE_2 &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].pDataUnit->Postroeno == TRUE)
		{
			if (fAttackAction(pHumanPlayer,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vId,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].vId) == 0)
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vId);
			}
		}
	}
	// Рушим домик 2
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_2].vIdForComments == COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_2 &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_2].pDataUnit->vId == ID_UNIT_BUILD_DOM &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed > 2 * 60)
	{
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vIdForComments == COMMENT_TOWER_FOR_BLOCK_SHADE_1 &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].pDataUnit->Postroeno == TRUE)
		{
			if (fAttackAction(pHumanPlayer,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vId,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_2].vId) == 0)
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vId);
			}
		}
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vIdForComments == COMMENT_TOWER_FOR_BLOCK_SHADE_2 &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].pDataUnit->Postroeno == TRUE)
		{
			if (fAttackAction(pHumanPlayer,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vId,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_2].vId) == 0)
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vId);
			}
		}
	}
	// Рушим домик 3
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_3].vIdForComments == COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_3 &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_3].pDataUnit->vId == ID_UNIT_BUILD_DOM &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed > 2 * 60)
	{
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vIdForComments == COMMENT_TOWER_FOR_BLOCK_SHADE_1 &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].pDataUnit->Postroeno == TRUE)
		{
			if (fAttackAction(pHumanPlayer,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vId,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_3].vId) == 0)
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vId);
			}
		}
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vIdForComments == COMMENT_TOWER_FOR_BLOCK_SHADE_2 &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].pDataUnit->Postroeno == TRUE)
		{
			if (fAttackAction(pHumanPlayer,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vId,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_3].vId) == 0)
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vId);
			}
		}
	}
	// Рушим домик 4
	if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_4].vIdForComments == COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_4 &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_4].pDataUnit->vId == ID_UNIT_BUILD_DOM &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed > 2 * 60)
	{
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vIdForComments == COMMENT_TOWER_FOR_BLOCK_SHADE_1 &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].pDataUnit->Postroeno == TRUE)
		{
			if (fAttackAction(pHumanPlayer,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vId,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_4].vId) == 0)
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_1].vId);
			}
		}
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vIdForComments == COMMENT_TOWER_FOR_BLOCK_SHADE_2 &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].pDataUnit->Postroeno == TRUE)
		{
			if (fAttackAction(pHumanPlayer,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vId,
						  pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE_4].vId) == 0)
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_TOWER_FOR_BLOCK_SHADE_2].vId);
			}
		}
	}
	// Если на нулевой базе и не помогаем, маны ноль, то беги на позицию репаир 3
	if (pHumanPlayer->vFlagEscapeFromTheBase == FALSE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelping == FALSE &&
		&pHumanPlayer->vBase &&
		fFindBaseByDataUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit) == 0 &&
		fRemotenessBase(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit) <= 0 &&
		GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_LIFE) < 1)
	{
		fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
				if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,
								  pHumanPlayer->vBase.vRepairPos[3].vInt3,
								  ACTION_BLINK) == 1);
	}
	// Если не хватает хипов то валим с базы
	/*if (pHumanPlayer->vFlagEscapeFromTheBase == FALSE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelping == TRUE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelpBase &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelpBase->pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments != COMMENT_MAIN_WALL &&
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.9)))
	{
		pHumanPlayer->vFlagEscapeFromTheBase = TRUE;
		pHumanPlayer->vStageEscapeFromTheBase = 6;
		fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
	}*/
	// Отпрыгни если ударили
	if (pHumanPlayer->vFlagDearBase == TRUE &&
		pHumanPlayer->vFlagEscapeFromTheBase == FALSE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vHelping == TRUE &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vTimeJumpMainHuman > 3 &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->Atakovan == FALSE &&
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
		(GetUnitState(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.9)))
	{
		pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->WhichUnit);
		if (1)//pHumanPlayer->vIdOrder == ID_ORDER_WAITING)
		{
			fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
			if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,fJumpBack(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit),ACTION_BLINK) == 1)
			{
				pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->Atakovan = TRUE;
				pHumanPlayer->vTimeJumpMainHuman = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
			}
		}
	}
	// База слаерка
	if (pHumanPlayer->vBase.vSlayerBaze == TRUE &&
		pHumanPlayer->vWallCreated == TRUE &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit &&
		pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed > 60 * 2.5)
	{
		pHumanPlayer->vBase.vSlayerBaze = FALSE;
	}
	// Вал
	if (pHumanPlayer->vBase.vSlayerBaze == FALSE &&
		pHumanPlayer->vBase.vNBase != DO_NOT_FIND_BASE &&
		pHumanPlayer->vCurrentChain &&
		pHumanPlayer->vCurrentChain->vN > 33 &&
		pHumanPlayer->vCurrentChain->vN < pHumanPlayer->MAX_Q_FOR_MASS_CHAINS - 500)
	{
		if (pHumanPlayer->vWallCreated == FALSE &&
			pHumanPlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_BUILD_WALL_BROWN,COMMENT_MAIN_WALL) == true &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL)
		{
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vTimeGoBuild = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
			pHumanPlayer->vWallCreated = TRUE;
		}
		if (pHumanPlayer->vWallCreated == TRUE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments != COMMENT_MAIN_WALL)
		{
			pHumanPlayer->vBase.vWallCreated = FALSE;
			pHumanPlayer->vWallCreated = FALSE;
		}
		if (pHumanPlayer->vWallCreated == TRUE &&
			pHumanPlayer->vBase.vWallCreated == TRUE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
			(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_BROWN ||
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_YELLOW))
		{
			pHumanPlayer->vBase.vWallCreated = FALSE;
		}
		if (pHumanPlayer->vBase.vWallCreated == FALSE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == TRUE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_BROWN &&
			pHumanPlayer->vForerunnerChainTemp &&
			pHumanPlayer->vForerunnerChainTemp->vId != ID_UNIT_BUILD_WALL_YELLOW)
		{
			pHumanPlayer->vFlagRepair = FALSE;
			sprintf(vBuf,"%s\0","Улучшаем коричневый вал!");
			if (fNewChainActionUpgrade(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),ID_UNIT_BUILD_WALL_YELLOW,COMMENT_MAIN_WALL,vBuf) == TRUE);
		}
		if (pHumanPlayer->vBase.vWallCreated == FALSE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == TRUE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_YELLOW &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Upgrade == FALSE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Atakovan == FALSE &&
			pHumanPlayer->vForerunnerChainTemp &&
			pHumanPlayer->vForerunnerChainTemp->vId != ID_UNIT_BUILD_WALL_VIOLET)
		{
			sprintf(vBuf,"%s\0","Улучшаем фиолетовый вал!");
			if (fNewChainActionUpgrade(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),ID_UNIT_BUILD_WALL_VIOLET,COMMENT_MAIN_WALL,vBuf) == TRUE);
		}
		if (pHumanPlayer->vBase.vWallCreated == FALSE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Postroeno == TRUE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].pDataUnit->Upgrade == FALSE)
		{
			pHumanPlayer->vBase.vWallCreated = TRUE;
		}
		if (pHumanPlayer->vBase.vWallCreated == TRUE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments != COMMENT_MAIN_WALL &&
			pHumanPlayer->vCurrentChain &&
			pHumanPlayer->vCurrentChain->vN >= 30)
		{
			pHumanPlayer->vBase.vWallCreated = FALSE;
		}
		if (pHumanPlayer->vBase.vWallCreated == FALSE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments != COMMENT_MAIN_WALL &&
			pHumanPlayer->vBase.vMainWall &&
			pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vTimeGoBuild > 5)
		{
			if (fG(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.X,
				   pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.Y,
			       fConvertIToRX(pHumanPlayer->vBase.vMainWall->vInt3),
			       fConvertIToRY(pHumanPlayer->vBase.vMainWall->vInt3)) < (128 * 2))
			{
				if (fBuild(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,pHumanPlayer->vBase.vMainWall->vInt3,ID_UNIT_BUILD_WALL_BROWN) == TRUE)
				{
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vTimeGoBuild = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
					pHumanPlayer->vWallCreated = FALSE;
				}
			}
			else if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
				     pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vAction == ACTION_WAITING &&
					 pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vActionFinish == 1 &&
					 (vDataUnits[10 + 0].pDataUnit == NULL || (vDataUnits[10 + 0].pDataUnit &&
					 pHumanPlayer->vBase.vMainWall &&
				     IsUnitVisible(vDataUnits[10 + 0].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
				     fG(vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X,
				     vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y,
			         fConvertIToRX(pHumanPlayer->vBase.vMainWall->vInt3),
			         fConvertIToRY(pHumanPlayer->vBase.vMainWall->vInt3)) > (128 * 3))) &&
					 (vDataUnits[10 + 1].pDataUnit == NULL || (vDataUnits[10 + 1].pDataUnit &&
				     IsUnitVisible(vDataUnits[10 + 1].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
				     fG(vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X,
				     vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y,
			         fConvertIToRX(pHumanPlayer->vBase.vMainWall->vInt3),
			         fConvertIToRY(pHumanPlayer->vBase.vMainWall->vInt3)) < (128 * 3))))
			{
				fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
				if (fGoToAction(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId,
								  pHumanPlayer->vBase.vRepairPos[3].vInt3,
								  ACTION_BLINK) == 1);
			}
			//sprintf(vBuf,"%s\0","Строим кориченвый вал по новой!");
			//if (fNewChainActionBuild(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),COMMENT_MAIN_WALL,ID_UNIT_BUILD_WALL_BROWN,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
		}
		if (pHumanPlayer->vBase.vWall2Created == FALSE &&
			pHumanPlayer->vBase.vWallCreated == TRUE &&
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_WALL].vIdForComments == COMMENT_MAIN_WALL &&
			//pHumanPlayer->vBlockRepair == FALSE &&
			pHumanPlayer->vBase.vMainWall &&
			pHumanPlayer->vParamPlayer.vTimerGetElapsed > 60 * 5)
		{
			if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].vIdForComments != COMMENT_HOUSE_FOR_BLOCK_VAMPIRE)
			{
				if (fG(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.X,
					   pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->LastCoordinates.Y,
					   fConvertIToRX(pHumanPlayer->vBase.vMainWall->vInt3),
					   fConvertIToRY(pHumanPlayer->vBase.vMainWall->vInt3)) < (128 * 2) &&
					   pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
						 pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vAction == ACTION_WAITING &&
						 pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit->vActionFinish == 1 &&
						 (vDataUnits[10 + 0].pDataUnit == NULL || (vDataUnits[10 + 0].pDataUnit &&
						 pHumanPlayer->vBase.vMainWall &&
						 IsUnitVisible(vDataUnits[10 + 0].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
						 fG(vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X,
						 vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y,
						 fConvertIToRX(pHumanPlayer->vBase.vMainWall->vInt3),
						 fConvertIToRY(pHumanPlayer->vBase.vMainWall->vInt3)) > (128 * 5))) &&
						 (vDataUnits[10 + 1].pDataUnit == NULL || (vDataUnits[10 + 1].pDataUnit &&
						 IsUnitVisible(vDataUnits[10 + 1].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
						 fG(vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X,
						 vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y,
						 fConvertIToRX(pHumanPlayer->vBase.vMainWall->vInt3),
						 fConvertIToRY(pHumanPlayer->vBase.vMainWall->vInt3)) < (128 * 5))))
				{
					//pHumanPlayer->vBlockRepair = TRUE;
					fFinishActionUnit(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
					sprintf(vBuf,"%s\0","Строим второй вал от вампа");
					if (fNewChainActionBuild(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),COMMENT_HOUSE_FOR_BLOCK_VAMPIRE,ID_UNIT_BUILD_WALL_BROWN,COMMENT_MAIN_HUMAN,vBuf) == TRUE);
				}
			}
			else
			{
				if (pHumanPlayer->vBase.vWallCreated == TRUE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].vIdForComments == COMMENT_HOUSE_FOR_BLOCK_VAMPIRE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].pDataUnit->Postroeno == TRUE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].pDataUnit->vId == ID_UNIT_BUILD_WALL_BROWN)
				{
					pHumanPlayer->vFlagRepair = FALSE;
					sprintf(vBuf,"%s\0","Улучшаем коричневый вал!");
					if (fNewChainActionUpgrade(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),ID_UNIT_BUILD_WALL_YELLOW,COMMENT_HOUSE_FOR_BLOCK_VAMPIRE,vBuf) == TRUE);
				}
				if (pHumanPlayer->vBase.vWallCreated == TRUE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].vIdForComments == COMMENT_HOUSE_FOR_BLOCK_VAMPIRE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].pDataUnit->Postroeno == TRUE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].pDataUnit->vId == ID_UNIT_BUILD_WALL_YELLOW &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].pDataUnit->Upgrade == FALSE)
				{
					sprintf(vBuf,"%s\0","Улучшаем фиолетовый вал!");
					if (fNewChainActionUpgrade(pHumanPlayer,TRUE,fFindFreeNChain(pHumanPlayer),ID_UNIT_BUILD_WALL_VIOLET,COMMENT_HOUSE_FOR_BLOCK_VAMPIRE,vBuf) == TRUE);
				}
				if (pHumanPlayer->vBase.vWallCreated == TRUE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].vIdForComments == COMMENT_HOUSE_FOR_BLOCK_VAMPIRE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].pDataUnit->Postroeno == TRUE &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].pDataUnit->vId == ID_UNIT_BUILD_WALL_VIOLET &&
					pHumanPlayer->vParamPlayer.vUnit[COMMENT_HOUSE_FOR_BLOCK_VAMPIRE].pDataUnit->Upgrade == FALSE)
				{
					pHumanPlayer->vBase.vWall2Created = TRUE;
				}
			}
		}
	}
}

void fGameHuman()
{	
	HTIMER t = GetExpiredTimer();
	if (t == NULL) return;
	real vTimerGetElapsed = TimerGetElapsed(vTimerGame);
	if (vAuthorization == 0)
	{
		vAuthorization = GetStoredInteger(vAuthorizationCache,"Map","vAuthorization");
		if (vAuthorization == 0)
		{
			if(vTimerGetElapsed>3*60)
			{
				fEndGame();
				return;
			}
		}
	}
	HumanPlayer *pHumanPlayer;
	int vvh;
	for (vvh = 0; vvh < vCountHumans; vvh++)
	{
	//pHumanPlayer = fGetHumanePlayer(t);
	pHumanPlayer = NULL;
	pHumanPlayer = (HumanPlayer *)&pHumanPlayerGlobal[vvh];//LoadInteger(vHT,t,CONST_AI_PLAYER);
	if (pHumanPlayer == NULL) continue;//return;
	if (vDataUnits[pHumanPlayer->vParamPlayer.vAI].pDataUnit == NULL) continue;
	if (pHumanPlayer->vParamPlayer.vSyncEnd == FALSE)
	{
		if (fSyncBegin(pHumanPlayer) == FALSE) continue;//return;
		if (pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit == NULL)
		{
			pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit = vDataUnits[pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId].pDataUnit;
			pHumanPlayer->vActionStackForUnitsMainHuman.first->vIdDataUnit2.pDataUnit = vDataUnits[pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId].pDataUnit;
			pHumanPlayer->vActionStackForUnits.first->vIdDataUnit2.pDataUnit = vDataUnits[pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId].pDataUnit;
			pHumanPlayer->vActionStackForUnitsGoTo.first->vIdDataUnit2.pDataUnit = vDataUnits[pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId].pDataUnit;
		}
	}
	//pHumanPlayer->vParamPlayer.vTimerPlayer = t;
	pHumanPlayer->vParamPlayer.vTimerGetElapsed = vTimerGetElapsed;
	if (pHumanPlayer->vFlagDearBase == FALSE && 
		vDataUnits[pHumanPlayer->vParamPlayer.vAI].pDataUnit &&
		pHumanPlayer->vParamPlayer.vTimerGetElapsed < 1 * 60)
	{
		vDataUnits[pHumanPlayer->vParamPlayer.vAI].pDataUnit = NULL;
	}
	// По смерти игрока
	if (pHumanPlayer->vStage >= 0 &&
		(vDataUnits[pHumanPlayer->vParamPlayer.vAI].pDataUnit == NULL ||
		(vDataUnits[pHumanPlayer->vParamPlayer.vAI].pDataUnit != NULL && vDataUnits[pHumanPlayer->vParamPlayer.vAI].pDataUnit->Dead == TRUE)))
	{
		// Закинуть черные здания в стак Енеми 2
		StackForUnits *current = pHumanPlayer->vActionStackForUnits.first;
		StackForUnits *next = NULL;
		while (current && (unsigned int)current != 0xdddddddd && (unsigned int)current != 0xcdcdcdcd && (unsigned int)current != 0xcccccccc)
		{
			if (current->vIdDataUnit2.pDataUnit &&
				current->vIdDataUnit2.pDataUnit->Zdanie == TRUE &&
				(unsigned int)current->vIdDataUnit2.pDataUnit->WhichUnit != 0xdddddddd &&
				(unsigned int)current->vIdDataUnit2.pDataUnit->WhichUnit != 0xcdcdcdcd &&
				(unsigned int)current->vIdDataUnit2.pDataUnit->WhichUnit != 0xcccccccc)
			{
				pDataHumans->vActionStackForUnitsEnemy2.fAddStackForUnits(current->vIdDataUnit2.pDataUnit->vIdDataUnit,current->vIdDataUnit2.pDataUnit,COMMENT_NEW_UNIT);
			}
			current = current->next;
		}
		// Дать приказ бежать с базы убитого
		for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
		{
			if (pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vAI != pHumanPlayer->vParamPlayer.vAI &&
				pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vIdForComments == COMMENT_MAIN_HUMAN &&
				pHumanPlayerGlobal[pHumanPlayer->vvi].vHelpBase == &pHumanPlayer->vBase)
				//pHumanPlayerGlobal[pHumanPlayer->vvi].vBase.vNBase == pHumanPlayer->vBase.vNBase &&
				//pHumanPlayerGlobal[pHumanPlayer->vvi].vFlagDearBase == FALSE)
			{
				pHumanPlayerGlobal[pHumanPlayer->vvi].vFlagEscapeFromTheBase = TRUE;
				pHumanPlayerGlobal[pHumanPlayer->vvi].vStageEscapeFromTheBase = 6;
				fFinishActionUnit(pHumanPlayerGlobal[pHumanPlayer->vvi].vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].vId);
			}
		}
		pHumanPlayer->vBase.vNBase = DO_NOT_FIND_BASE;
		pHumanPlayer->vBase.vMainWall = NULL;
		pHumanPlayer->vBase.pHumanPlayer = NULL;
		pHumanPlayer->vWallCreated = FALSE;
		pHumanPlayer->vBase.vWallCreated = FALSE;
		fDelAllChainsPlayer(pHumanPlayer);// Удалить все цепочки игрока
		for (pHumanPlayer->vvi = 0; pHumanPlayer->vvi < vCountHumans; pHumanPlayer->vvi++)
		{
			if (vMapBases.fFreePosRepair(&pHumanPlayerGlobal[pHumanPlayer->vvi].vBase,pHumanPlayer) == TRUE)
			{
				break;
			}
		}
		//
		if (pHumanPlayer->vParamPlayer.vTimerPlayer > 0)
		{
			//DestroyTimer(pHumanPlayer->vParamPlayer.vTimerPlayer);
		}
		fDelDataUnit2(vDataUnits[pHumanPlayer->vParamPlayer.vAI].vId);
		SaveInteger(vHT,pHumanPlayer->vParamPlayer.vTimerPlayer,CONST_AI_PLAYER,(integer)NULL);
		pHumanPlayer->vParamPlayer.vTimerPlayer = NULL;
		//return;
		continue;
	}
	try
	{
	fPreActionsHuman(pHumanPlayer);
	}
	catch (const char* error_message)
	{
		MessageBoxA(NULL,error_message,"Error fPreActionsHuman!",MB_OK | MB_ICONWARNING);
		sprintf(vBuf,"fPreActionsHuman = %s\0",error_message);
		fLog(66,vBuf);
	}
	
	if (pHumanPlayer->vParamPlayer.vBusy == TRUE)
	{
		return;
	}
	try
	{
	fActionsUnitsGoTo(pHumanPlayer);
	}
	catch (const char* error_message)
	{
		MessageBoxA(NULL,error_message,"Error fActionsUnitsGoTo!",MB_OK | MB_ICONWARNING);
		sprintf(vBuf,"fActionsUnitsGoTo = %s\0",error_message);
		fLog(66,vBuf);
	}
	try
	{
	fMapRoutingChains(pHumanPlayer);
	}
	catch (const char* error_message)
	{
		MessageBoxA(NULL,error_message,"Error fMapRoutingChains!",MB_OK | MB_ICONWARNING);
		sprintf(vBuf,"fMapRoutingChains = %s\0",error_message);
		fLog(66,vBuf);
	}
	try
	{
	fActionsHuman(pHumanPlayer);
	}
	catch (const char* error_message)
	{
		MessageBoxA(NULL,error_message,"Error fActionsHuman!",MB_OK | MB_ICONWARNING);
		sprintf(vBuf,"fActionsHuman = %s\0",error_message);
		fLog(66,vBuf);
	}
	try
	{
	fActionsSlayer(pHumanPlayer);
	}
	catch (const char* error_message)
	{
		MessageBoxA(NULL,error_message,"Error fActionsSlayer!",MB_OK | MB_ICONWARNING);
		sprintf(vBuf,"fActionsSlayer = %s\0",error_message);
		fLog(66,vBuf);
	}
	////////fActionsSlayer(pHumanPlayer);
	//return;
	/*integer vStage = pHumanPlayer->vParamPlayer.vStage;
	DataUnit *pDataUnit;
	Integer vIdOrder;
	if (vStage >= 45 && vStage <= 45)
	{
		switch(vStage)
		{
		case 45:
			if (pHumanPlayer->vActionStackForUnits.Busy == TRUE)
				return;
			pHumanPlayer->vParamPlayer.vBusy = TRUE;
			pDataUnit = NULL;
			pDataUnit = pHumanPlayer->vActionStackForUnits.fGetDataUnit(COMMENT_NEW_UNIT,ID_UNIT_WORKER,HARVEST_FALSE);
			if (pDataUnit)
			{
				KillUnit(pDataUnit->WhichUnit);
				pDataUnit = NULL;
				pDataUnit = pHumanPlayer->vActionStackForUnits.fGetDataUnit(COMMENT_FIRST_DOM);
				if (pDataUnit)
				{
					if (pDataUnit->Postroeno == TRUE)
					{
						IssueImmediateOrderById(pDataUnit->WhichUnit,ID_UNIT_WORKER);
					}
				}
				vFlagTest++;
			}
			pHumanPlayer->vParamPlayer.vBusy = FALSE;
			return;
		}
	}*/
	}
}

bool fSyncBegin(HumanPlayer *pHumanPlayer)
{
	if (pHumanPlayer == NULL) return FALSE;
	/*if (pHumanPlayer->vParamPlayer.vCountForLoopGame > 0.1 * 100  * 40)
	{
		if (pHumanPlayer->vParamPlayer.vTimerPlayer > 0)
		{
			DestroyTimer(pHumanPlayer->vParamPlayer.vTimerPlayer);
			return FALSE;
		}
	}
	pHumanPlayer->vParamPlayer.vCountForLoopGame++;
	if (pHumanPlayer->vParamPlayer.vSync == FALSE)
	{
		sprintf(vKeyLocalPlayer,"%d\0",GetPlayerColor(GetLocalPlayer()));
		StoreInteger(vSyncCache,pHumanPlayer->vParamPlayer.vKeyAIPlayer,vKeyLocalPlayer,1);
		SyncStoredInteger(vSyncCache,pHumanPlayer->vParamPlayer.vKeyAIPlayer,vKeyLocalPlayer);
		StoreInteger(vSyncCache,pHumanPlayer->vParamPlayer.vKeyAIPlayer,vKeyLocalPlayer,0);
		sprintf(vKeyLocalPlayer,"\0");
		pHumanPlayer->vParamPlayer.vSync = TRUE;
	}
	if (pHumanPlayer->vParamPlayer.vSync == TRUE)
	{
		//sprintf(vBuf,"%d\0",vCountPlayersUser);
		//fLog(31,vBuf);
		for (int vvi = 0; vvi < vCountPlayersUser; vvi++)
		{
			if (pPlayerUser[vvi].vLeave == TRUE)
			{
				fLog(32,"+++");
			}
			if (pPlayerUser[vvi].vLeave == FALSE)
			{
				for (int vvj = 0; vvj < vCountHumans; vvj++)
				{
					if (GetStoredInteger(vSyncCache,pHumanPlayerGlobal[vvj].vParamPlayer.vKeyAIPlayer,pPlayerUser[vvi].vKeyPlayer) == 0)
					{
						return FALSE;
					}
				}
			}
		}
	}
	fLog(0,"0");
	fLog(30,"---");*/
	pHumanPlayer->vParamPlayer.vSyncEnd = TRUE;
	return TRUE;
}

bool fAddDataUnitInRange(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit)
{
	if (pHumanPlayer == NULL || pDataUnit == NULL) return FALSE;
	bool vFlag;
	vFlag = FALSE;
	pHumanPlayer->vId = GetUnitTypeId(pDataUnit->WhichUnit);
	if (pHumanPlayer->vId != 0)
	{
		if (fGetDataUnit(pDataUnit->WhichUnit) != NULL)
		{
			return TRUE;
		}
		if (pHumanPlayer->vId != pDataUnit->vId)
		{
			//pDataUnit->vId = pHumanPlayer->vId;
			//fDelDataUnit(pDataUnit->vIdDataUnit);
		}
		if (pHumanPlayer->vId != ID_UNIT_BUILD_WALL_BROWN)
		{
			//return;
		}
		else
		{
			pHumanPlayer->vId = pHumanPlayer->vId;
			//return;
		}
		//return;
	}
	else
	{
		//fDelDataUnit(pDataUnit->vIdDataUnit);
		//return;
		//pHumanPlayer->vId = pHumanPlayer->vId;
	}
	if (pDataUnit->LastCoordinates.X == 0 &&
		pDataUnit->LastCoordinates.Y == 0)
	{
		fLog(5,pDataUnit->vName);
		fDelDataUnit(pDataUnit->vIdDataUnit);
		fAddAllDataUnitOfPlayer(pHumanPlayer->vParamPlayer.vPlayer);
		fWeCommentOnTheNew(pHumanPlayer,&pHumanPlayer->vActionStackForUnits);
		return TRUE;
	}
							pHumanPlayer->hGroupFarm = CreateGroup();
							GroupEnumUnitsInRange(pHumanPlayer->hGroupFarm,
												  pDataUnit->LastCoordinates.X,
												  pDataUnit->LastCoordinates.Y,
												  128*16,
												  NULL);
							do
							{
								pHumanPlayer->u = FirstOfGroup(pHumanPlayer->hGroupFarm);
								if (pHumanPlayer->u != 0)
								{
									pHumanPlayer->pDataUnit = fGetDataUnit(pHumanPlayer->u);
									pHumanPlayer->vId = GetUnitTypeId(pHumanPlayer->u);
									if (((pDataUnit->Zdanie == FALSE &&
										pHumanPlayer->pDataUnit == NULL) ||
										(pDataUnit->Zdanie == TRUE &&
										GetUnitX(pHumanPlayer->u) == pDataUnit->LastCoordinates.X &&
										GetUnitY(pHumanPlayer->u) == pDataUnit->LastCoordinates.Y))&&
										pHumanPlayer->vId == pDataUnit->vId &&
										pHumanPlayer->vParamPlayer.vPlayer == GetOwningPlayer(pHumanPlayer->u))
									{
										RemoveUnit(pDataUnit->WhichUnit);
										pDataUnit->WhichUnit = pHumanPlayer->u;
										sprintf(pDataUnit->vKeyUnit,"%d\0",pDataUnit->WhichUnit);
										pDataUnit->LastCoordinates.X = GetUnitX(pDataUnit->WhichUnit);
										pDataUnit->LastCoordinates.Y = GetUnitY(pDataUnit->WhichUnit);
										pDataUnit->Dead = FALSE;
										/*if (pDataUnit->vGoTo == TRUE)
										{
											FlushGameCache(pDataUnit->vSyncCache);
											pDataUnit->vSyncCache = InitGameCache(pDataUnit->vKeyUnit);
										}*/
										vFlag = TRUE;
										goto m1;
									}
								}
								GroupRemoveUnit(pHumanPlayer->hGroupFarm,pHumanPlayer->u);
							}
							while (pHumanPlayer->u != 0);
m1:
							DestroyGroup(pHumanPlayer->hGroupFarm);
	if (vFlag == FALSE)
	{
							pHumanPlayer->hGroupFarm = CreateGroup();
							GroupEnumUnitsInRange(pHumanPlayer->hGroupFarm,
												  pDataUnit->LastCoordinates.X,
												  pDataUnit->LastCoordinates.Y,
												  128*4,
												  NULL);
							do
							{
								pHumanPlayer->u = FirstOfGroup(pHumanPlayer->hGroupFarm);
								if (pHumanPlayer->u != 0)
								{
									if (fGetDataUnit(pHumanPlayer->u) == NULL &&
										pDataUnit->Zdanie == TRUE &&
										GetUnitX(pHumanPlayer->u) == pDataUnit->LastCoordinates.X &&
										GetUnitY(pHumanPlayer->u) == pDataUnit->LastCoordinates.Y &&
										pDataUnit->vId == GetUnitTypeId(pHumanPlayer->u) &&
										pHumanPlayer->vParamPlayer.vPlayer == GetOwningPlayer(pHumanPlayer->u))
									{
										RemoveUnit(pHumanPlayer->u);
										vFlag = TRUE;
									}
								}
								GroupRemoveUnit(pHumanPlayer->hGroupFarm,pHumanPlayer->u);
							}
							while (pHumanPlayer->u != 0);
							DestroyGroup(pHumanPlayer->hGroupFarm);
	}
	if (vFlag == FALSE)
	{
		fDelDataUnit2(pDataUnit->vIdDataUnit);
	}
	return vFlag;
}

// Детонировать всех
bool fDetonateAll(HumanPlayer *pHumanPlayer, integer vId, ActionStackForUnits *pActionStackForUnits)
{
	if (pHumanPlayer == NULL || pActionStackForUnits == NULL) return FALSE;
	StackForUnits *current;
m1:
	current = pActionStackForUnits->first;
	while (current && (unsigned int)current != 0xdddddddd)
	{
		if (current->vIdDataUnit2.pDataUnit)
		{
			if (current->vIdDataUnit2.pDataUnit->vId == vId)
			{
				fAddDataUnitInRange(pHumanPlayer,current->vIdDataUnit2.pDataUnit);
				if (current->vIdDataUnit2.pDataUnit != NULL &&
					(unsigned int)current->vIdDataUnit2.pDataUnit != 0xdddddddd)
				{
					//IssuePointOrderById(current->vIdDataUnit2.pDataUnit->WhichUnit,
					//					ID_ORDER_DETONATE,
					//					current->vIdDataUnit2.pDataUnit->LastCoordinates.X,
					//					current->vIdDataUnit2.pDataUnit->LastCoordinates.Y);
					if (IssuePointOrderById(current->vIdDataUnit2.pDataUnit->WhichUnit,
											ID_ORDER_DETONATE,
											GetUnitX(current->vIdDataUnit2.pDataUnit->WhichUnit),
											GetUnitY(current->vIdDataUnit2.pDataUnit->WhichUnit)) == TRUE)
					{
						pHumanPlayer->vDelWorkers = TRUE;
						//return TRUE;
					}
					else
					{
						pActionStackForUnits->fFreeStackForUnits(current->vIdDataUnit2.vId);
					}
				}
			}
		}
		current = current->next;
	}
	return TRUE;
}

unsigned short fTrainActionCountUnits(HumanPlayer *pHumanPlayer, unsigned short vComment, integer vIdDataUnitBuild, integer vIdDataUnitTrain, unsigned short vCount, ActionStackForUnits *pActionStackForUnits)
{
	if (pHumanPlayer == NULL || pActionStackForUnits == NULL) return FALSE;
	if (vIdDataUnitBuild <= 0) return 0;
	unsigned short vFlag = 0;
	DataUnit *pDataUnit;
	pDataUnit = NULL;
	for (unsigned short vvi = 0; vvi < vCount; vvi++)
	{
		pDataUnit = pActionStackForUnits->fGetDataUnit(vComment,vIdDataUnitBuild);
		if (pDataUnit && (unsigned int)pDataUnit != 0xdddddddd)
		{
			if (pDataUnit->Postroeno == TRUE || fCompliteBuild(pDataUnit,pHumanPlayer->vParamPlayer.vTimerGetElapsed) == TRUE)
			{
				//fGetLastCoordinates(pDataUnit);
				if (fIsEnoughResourses(pHumanPlayer->vParamPlayer.vPlayer,vIdDataUnitTrain) == TRUE)
				{
					fAddDataUnitInRange(pHumanPlayer,pDataUnit);
					IssueImmediateOrderById(pDataUnit->WhichUnit,vIdDataUnitTrain);
					vFlag = 1;
				}
			}
			else
			{
				pDataUnit->fGetPostroeno();
			}
		}
	}
	return vFlag;
}

unsigned short fTrainAction(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, integer vIdDataUnitBuild, unsigned short vCount)
{
	if (vIdDataUnitBuild <= 0) return 0;
	if (pHumanPlayer->vDelWorkers == TRUE &&
		vIdDataUnitBuild == ID_UNIT_WORKER)
	{
		return 0;
	}
	unsigned short vFlag = 0;
	if (pDataUnit && (unsigned int)pDataUnit != 0xdddddddd)
	{
		if (pDataUnit->Postroeno == TRUE || fCompliteBuild(pDataUnit,pHumanPlayer->vParamPlayer.vTimerGetElapsed) == TRUE)
		{
			//fGetLastCoordinates(pDataUnit);
			for (unsigned short vvi = 0; vvi < vCount; vvi++)
			{
				if (fIsEnoughResourses(pHumanPlayer->vParamPlayer.vPlayer,vIdDataUnitBuild) == TRUE)
				{
					if(IssueImmediateOrderById(pDataUnit->WhichUnit,vIdDataUnitBuild) == TRUE)
					{
						if (fIsSlayer(vIdDataUnitBuild)) pHumanPlayer->vDelWorkers = FALSE;
						vFlag = 1;
					}
					else
					{
						vFlag = 3;
						if (fAddDataUnitInRange(pHumanPlayer,pDataUnit) == FALSE)
						{
							vFlag = 2;
						}
					}
				}
				else if (GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_FOOD_CAP) ==
					     GetPlayerState(pHumanPlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_FOOD_USED))
				{
					if (vIdDataUnitBuild == ID_UNIT_WORKER)
					{
						vFlag = 1;
						return vFlag;
					}
					if (fIsSlayer(vIdDataUnitBuild))
					{
						pHumanPlayer->vUnitDel = pHumanPlayer->vActionStackForUnitsWorkers.first;
						if (pHumanPlayer->vUnitDel && pHumanPlayer->vUnitDel->vIdDataUnit2.pDataUnit)
						{
							if (IssuePointOrderById(pHumanPlayer->vUnitDel->vIdDataUnit2.pDataUnit->WhichUnit,
													ID_ORDER_DETONATE,
													GetUnitX(pHumanPlayer->vUnitDel->vIdDataUnit2.pDataUnit->WhichUnit),
													GetUnitY(pHumanPlayer->vUnitDel->vIdDataUnit2.pDataUnit->WhichUnit)) == TRUE)
							{
								pHumanPlayer->vDelWorkers = TRUE;
							}
						}
					}
				}
			}
			return vFlag;
		}
		else
		{
			pDataUnit->fGetPostroeno();
		}
	}
	return vFlag;
}

unsigned short fTrainActionResearch(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, integer vNResearch)
{
	integer vId; 
	unsigned short vFlag = 0;
	if (pDataUnit && (unsigned int)pDataUnit != 0xdddddddd)
	{
		if (pDataUnit->Postroeno == TRUE || fCompliteBuild(pDataUnit,pHumanPlayer->vParamPlayer.vTimerGetElapsed) == TRUE)
		{
			if (pDataUnit->Researching == FALSE || fCompliteResearch(pDataUnit,pHumanPlayer->vParamPlayer.vTimerGetElapsed) == TRUE)
			{
				//fGetLastCoordinates(pDataUnit);
				if (fIsEnoughResourses(pHumanPlayer->vParamPlayer.vPlayer,&pHumanPlayer->vParamPlayer,vNResearch,&vId) == TRUE)
				{
					fAddDataUnitInRange(pHumanPlayer,pDataUnit);
					if(IssueImmediateOrderById(pDataUnit->WhichUnit,vId) == TRUE)
					{
						pDataUnit->vNResearch = vNResearch;
						vFlag = 1;
					}
				}
				return vFlag;
			}
		}
		else
		{
			pDataUnit->fGetPostroeno();
		}
	}
	return vFlag;
}

unsigned short fAttackAction(HumanPlayer *pHumanPlayer, unsigned short vIdDataUnit, unsigned short vIdDataUnit2)
{
	if (fGetActionUnit(vIdDataUnit) == ACTION_WAITING && fGetActionUnitFinish(vIdDataUnit) == 1)
	{
		fFreeActionUnit(vIdDataUnit);
		if (fUnitAttack(vIdDataUnit,vIdDataUnit2) == 1)
		{
			return 1;
		}
		else
		{
			DataUnit *pDataUnit;
			pDataUnit = fGetDataUnit(vIdDataUnit2);
			fAddDataUnitInRange(pHumanPlayer,pDataUnit);
			fFinishActionUnit(vIdDataUnit);
		}
	}
	return 0;
}

// Фильтр рабочих
integer fFilterWorker()
{
	HUNIT u = GetFilterUnit();
	if (u == NULL) return FALSE;
	integer vId;
	vId = GetUnitTypeId(u);
	if (vId == ID_UNIT_WORKER)
	{
		return TRUE;
	}
	return FALSE;
}

void fAddAllDataUnitOfPlayerWorker(HPLAYER vPlayer)
{
	group g=CreateGroup();
	unit u;
	GroupEnumUnitsOfPlayer(g,vPlayer,Filter(&fFilterWorker));
	do
	{
		u=FirstOfGroup(g);
		if (fGetDataUnit(u) == NULL)
		{
			fCreateDataUnit(u,THREAD_DO_NOT_MAIN);
		}
		GroupRemoveUnit(g,u);
	}
	while (u != 0);
	DestroyGroup(g);
}

void fActionsUnitsGoTo(HumanPlayer *pHumanPlayer)
{
	StackForUnits *current = pHumanPlayer->vActionStackForUnitsGoTo.first;
	//unsigned short vvi;
	//pHumanPlayer->pDataUnit;
	//pHumanPlayer->vCheck;
	//pHumanPlayer->vIdOrder;
	//pHumanPlayer->vMana;
	while(current)
	{
		pHumanPlayer->pDataUnit = current->vIdDataUnit2.pDataUnit;
		if (pHumanPlayer->pDataUnit && (unsigned int)pHumanPlayer->pDataUnit != 0xdddddddd)
		{
			if (pHumanPlayer->pDataUnit->vActionFinish == 0)
			{
				if ((pHumanPlayer->pDataUnit->vNPlayer >= 0 && pHumanPlayer->pDataUnit->vNPlayer <= 9 && pHumanPlayer->pDataUnit->vCountActions > 110) ||
					(pHumanPlayer->pDataUnit->vNPlayer >= 10 && pHumanPlayer->pDataUnit->vNPlayer <= 11 && pHumanPlayer->pDataUnit->vCountActions > 110))
				{
					fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
				}
				switch(pHumanPlayer->pDataUnit->vAction)
				{
				case ACTION_WAITING:
					break;
				case ACTION_GO:
				case ACTION_BLINK:
					switch(pHumanPlayer->pDataUnit->vActionN)
					{
					case ACTION_N_NEW:
						pHumanPlayer->pDataUnit->vCountActions++;
						if (pHumanPlayer->pDataUnit->vCountActions >= 0)
						{
							//StoreInteger(vSyncCache,pDataUnit->vKeyUnit,"vCheck",0);
							if (fUnitGoToInt(pHumanPlayer->pDataUnit->vIdDataUnit,
											 pHumanPlayer->pDataUnit->vIntForGoTo,
											 pHumanPlayer->pDataUnit->vAction,
											 LIMIT_MOVE) == 1)
							{
								pHumanPlayer->pDataUnit->vActionN = 0;
								pHumanPlayer->pDataUnit->vCountActions = 0;
							}
						}
						break;
					case 0:
						/*if (pHumanPlayer->pDataUnit->vAction == ACTION_BLINK &&
							pHumanPlayer->pDataUnit->vNPlayer >= 0 && pHumanPlayer->pDataUnit->vNPlayer <= 9 && pHumanPlayer->pDataUnit->vCountActions > 25 &&
							fIsRectToRect(&pHumanPlayer->pDataUnit->pPut->vRect4,&pHumanPlayer->pDataUnit->pPut->vRect5) == TRUE)
						{
							pHumanPlayer->pDataUnit->vLastAction = pHumanPlayer->pDataUnit->vAction;
							fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
							break;
						}*/
						pHumanPlayer->pDataUnit->vCountActions++;
						if ((pHumanPlayer->pDataUnit->vAction == ACTION_GO &&
							((pHumanPlayer->pDataUnit->vNPlayer >= 0 && pHumanPlayer->pDataUnit->vNPlayer <= 9 && pHumanPlayer->pDataUnit->vCountActions > 15) ||
							(pHumanPlayer->pDataUnit->vNPlayer >= 10 && pHumanPlayer->pDataUnit->vNPlayer <= 11 && pHumanPlayer->pDataUnit->vCountActions > 100))) ||
							(pHumanPlayer->pDataUnit->vAction == ACTION_BLINK &&
							(pHumanPlayer->pDataUnit->vNPlayer >= 0 && pHumanPlayer->pDataUnit->vNPlayer <= 9 && pHumanPlayer->pDataUnit->vCountActions > 25)))
						{
							if (pHumanPlayer->pDataUnit->Blinked == TRUE)
							{
								pHumanPlayer->pDataUnit->vAction = ACTION_BLINK;
								//if (pHumanPlayer->pDataUnit->vAction == ACTION_GO)
								//{
								//	pHumanPlayer->pDataUnit->vAction = ACTION_BLINK;
								//}
								//else if (pHumanPlayer->pDataUnit->vAction == ACTION_BLINK)
								//{
								//	pHumanPlayer->pDataUnit->vAction = ACTION_GO;
								//	pHumanPlayer->pDataUnit->vTimeGo = pHumanPlayer->vActionStackForUnits.pParamPlayer->vTimerGetElapsed;
								//}
								if (fGetDataUnit(pHumanPlayer->pDataUnit->pPut,pHumanPlayer->pDataUnit->vIntForGoTo))
								{
									pHumanPlayer->pDataUnit->vLastAction = pHumanPlayer->pDataUnit->vAction;
									fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
									break;
								}
							}
							else
							{
								pHumanPlayer->pDataUnit->vAction = ACTION_GO;
							}
							pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
							pHumanPlayer->pDataUnit->vCountActions = 0;
							pHumanPlayer->pDataUnit->vSyncClean = TRUE;
							break;
							//StoreInteger(vSyncCache,pDataUnit->vKeyUnit,"vCheck",0);
							//StoreReal(vSyncCache,pDataUnit->vKeyUnit,"vTimerGetElapsedGoTo",0);
							//StoreInteger(vSyncCache,pDataUnit->vKeyUnit,"vActionN",0);
						}
						//if (fSync(pDataUnit) == FALSE) break;
						//if (fCheckSync(pDataUnit) == FALSE) break;
						pHumanPlayer->vCheck = fCheckGoTo(pHumanPlayer->pDataUnit->vIdDataUnit);
						if (pHumanPlayer->vCheck == 1)
						{
							//StoreInteger(vSyncCache,pDataUnit->vKeyUnit,"vCheck",vCheck);
							//SyncStoredInteger(vSyncCache,pDataUnit->vKeyUnit,"vCheck");
							//StoreInteger(vSyncCache,pDataUnit->vKeyUnit,"vCheck",0);
							//if (fSync(pDataUnit) == FALSE) return;
								//GetStoredInteger
							//SyncStoredInteger
							pHumanPlayer->pDataUnit->vActionN++;
							pHumanPlayer->pDataUnit->vCountActions = 0;
							pHumanPlayer->pDataUnit->vSyncClean = FALSE;
							//fLog(0,"0");
							//fLog(600,"600");
						}
						break;
					case 1:
						pHumanPlayer->pDataUnit->vCountActions++;
						//if (fFreeSync(pHumanPlayer->pDataUnit) == FALSE) break;
						//if (fSync(pHumanPlayer->pDataUnit) == FALSE) break;
						//if (fCheckSync(pHumanPlayer->pDataUnit) == FALSE) break;
						//fLog(0,"0");
						//fLog(500,"500");
						//if (fCheckSync(pDataUnit) == TRUE)
						//if (GetStoredInteger(vSyncCache,pDataUnit->vKeyUnit,"vCheck") != 0)
						if (1)//pHumanPlayer->vBase.vSlayerBaze == FALSE)
						{
							if (pHumanPlayer->pDataUnit->vHelping == TRUE &&
								pHumanPlayer->pDataUnit->vAction == ACTION_BLINK &&
								//pHumanPlayer->pDataUnit->vBlockNewBlink == FALSE &&
								fIsMainHuman(pHumanPlayer->pDataUnit->vId) == TRUE &&
								fRemotenessBase(pHumanPlayer->pDataUnit) == 0)
							{
								pHumanPlayer->vMana = GetUnitState(pHumanPlayer->pDataUnit->WhichUnit, UNIT_STATE_MANA);
								if ((unsigned int)pHumanPlayer->vMana < pHumanPlayer->pDataUnit->pPut->vCountBlink)
								{
									//sprintf(pHumanPlayer->pDataUnit->pPut->vActionStr,"move");
									if (pHumanPlayer->pDataUnit->pPut->vCountBlink%2 == 1 || pHumanPlayer->vMana < 1)
									{
										                                //куда										//откуда
										if (pHumanPlayer->pDataUnit->pPut->vRect2.vX1 > pHumanPlayer->pDataUnit->pPut->vRect1.vX1)
										{
											pHumanPlayer->pDataUnit->pPut->vRect6.vX1 =
												pHumanPlayer->pDataUnit->pPut->vRect1.vX1 +
												(pHumanPlayer->pDataUnit->pPut->vRect2.vX1 - pHumanPlayer->pDataUnit->pPut->vRect1.vX1) /
												pHumanPlayer->pDataUnit->pPut->vCountBlink;
										}
										else
										{
											pHumanPlayer->pDataUnit->pPut->vRect6.vX1 =
												pHumanPlayer->pDataUnit->pPut->vRect1.vX1 -
												(pHumanPlayer->pDataUnit->pPut->vRect2.vX1 - pHumanPlayer->pDataUnit->pPut->vRect1.vX1) /
												pHumanPlayer->pDataUnit->pPut->vCountBlink;
										}
										if (pHumanPlayer->pDataUnit->pPut->vRect2.vY1 > pHumanPlayer->pDataUnit->pPut->vRect1.vY1)
										{
											pHumanPlayer->pDataUnit->pPut->vRect6.vY1 =
												pHumanPlayer->pDataUnit->pPut->vRect1.vY1 +
												(pHumanPlayer->pDataUnit->pPut->vRect2.vY1 - pHumanPlayer->pDataUnit->pPut->vRect1.vY1) /
												pHumanPlayer->pDataUnit->pPut->vCountBlink;
										}
										else
										{
											pHumanPlayer->pDataUnit->pPut->vRect6.vY1 =
												pHumanPlayer->pDataUnit->pPut->vRect1.vY1 -
												(pHumanPlayer->pDataUnit->pPut->vRect2.vY1 - pHumanPlayer->pDataUnit->pPut->vRect1.vY1) /
												pHumanPlayer->pDataUnit->pPut->vCountBlink;
										}
										if (vMapBases.fRemotenessBase(fConverterIX2RX(pHumanPlayer->pDataUnit->vRect1.vX1),fConverterIY2RY(pHumanPlayer->pDataUnit->vRect1.vY1)) <= 0 &&
											pHumanPlayer->pDataUnit->vHelpBase &&
											(vDataUnits[10 + 0].pDataUnit == NULL || (vDataUnits[10 + 0].pDataUnit &&
											 pHumanPlayer->pDataUnit->vHelpBase->vWallCreated &&
											 IsUnitVisible(vDataUnits[10 + 0].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
											 fG(vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X,
											 vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y,
											 fConvertIToRX(pHumanPlayer->pDataUnit->vHelpBase->vMainWall->vInt3),
											 fConvertIToRY(pHumanPlayer->pDataUnit->vHelpBase->vMainWall->vInt3)) < (128 * 7))) &&
											 (vDataUnits[10 + 1].pDataUnit == NULL || (vDataUnits[10 + 1].pDataUnit &&
											 pHumanPlayer->pDataUnit->vHelpBase->vWallCreated &&
											 IsUnitVisible(vDataUnits[10 + 1].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
											 fG(vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X,
											 vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y,
											 fConvertIToRX(pHumanPlayer->pDataUnit->vHelpBase->vMainWall->vInt3),
											 fConvertIToRY(pHumanPlayer->pDataUnit->vHelpBase->vMainWall->vInt3)) < (128 * 7))))
										{
											IssueImmediateOrderById(pHumanPlayer->pDataUnit->WhichUnit,ID_ORDER_STOP);
											break;
										}
										pHumanPlayer->pDataUnit->vIntForGoTo = fConvertXYToI(pHumanPlayer->pDataUnit->pPut->vRect6.vX1,
																							 pHumanPlayer->pDataUnit->pPut->vRect6.vY1);
										pHumanPlayer->pDataUnit->pPut->vRect6.vX2 = pHumanPlayer->pDataUnit->pPut->vRect6.vX1 + pHumanPlayer->pDataUnit->pPut->vDiff - 1;
										pHumanPlayer->pDataUnit->pPut->vRect6.vY2 = pHumanPlayer->pDataUnit->pPut->vRect6.vY1 + pHumanPlayer->pDataUnit->pPut->vDiff - 1;
										if (vMapBases.fRemotenessBase(fConvertIToRX(pHumanPlayer->pDataUnit->vIntForGoTo),fConvertIToRY(pHumanPlayer->pDataUnit->vIntForGoTo)) == 0 &&
											vMapBases.fCheckPos(pHumanPlayer->pDataUnit->vIntForGoTo,1,1) == TRUE)
										{
											//fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
											pHumanPlayer->pDataUnit->vSyncClean = TRUE;
											pHumanPlayer->pDataUnit->vAction = ACTION_GO;
											pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
											pHumanPlayer->pDataUnit->pPut->vCountBlink--;
											break;
										}
										else
										{
											pHumanPlayer->pDataUnit->vIntForGoTo = pHumanPlayer->pDataUnit->vInt3;
										}
									//pHumanPlayer->pDataUnit->vCountActions = 0;
									//fIssuePointOrderToRect(pHumanPlayer->pDataUnit->WhichUnit,
									//	                   "move",
									//					   &pHumanPlayer->pDataUnit->pPut->vRect5,
									//					   pHumanPlayer->pDataUnit->pPut->vRadius_Unit);
									//pHumanPlayer->pDataUnit->vActionFinish = 0;
									//pHumanPlayer->pDataUnit->vAction = ACTION_BLINK;
									//pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
									//pHumanPlayer->pDataUnit->vLastAction = ACTION_GO;
									//fLog(1,"1");
									}
									//else if (pHumanPlayer->pDataUnit->pPut->vCountBlink > 1)
									//{
										//pHumanPlayer->pDataUnit->vSyncClean = TRUE;
										//pHumanPlayer->pDataUnit->vAction = ACTION_BLINK;
										//pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
										/*pHumanPlayer->pDataUnit->pPut->vCountBlink--;
										if (pHumanPlayer->pDataUnit->pPut->vCountBlink != 0)
										{
											pHumanPlayer->pDataUnit->vIntForGoTo = vSizeMap;
										}
										else
										{
											pHumanPlayer->pDataUnit->vIntForGoTo = pHumanPlayer->pDataUnit->vInt3;
										}*/
										//pHumanPlayer->pDataUnit->vBlockNewBlink = TRUE;
										//break;
									//}
									
								}
							}
							pHumanPlayer->pDataUnit->vTimeGoTo = pHumanPlayer->vParamPlayer.vTimerGetElapsed;
							pHumanPlayer->vCheck = fGoTo(pHumanPlayer->pDataUnit->vIdDataUnit);
							if (pHumanPlayer->vCheck == 1)
							{
								pHumanPlayer->pDataUnit->vActionN++;
								pHumanPlayer->pDataUnit->vCountActions++;
							}
							else
							if (pHumanPlayer->vCheck == 2)
							{
								pHumanPlayer->pDataUnit->vLastAction = pHumanPlayer->pDataUnit->vAction;
								fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
								//pDataUnit->vActionN = ACTION_N_NEW;
								//pDataUnit->vCountActions = 0;
								//fLog(3,"3");
							}
							else
							if (pHumanPlayer->vCheck == 0)
							{
								//pDataUnit->vAction = ACTION_WAITING;
								pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
								pHumanPlayer->pDataUnit->vCountActions = 0;
								//fLog(4,"4");
							}
						}
						break;
					case 2:
						fExpiredTimerGoTo(pHumanPlayer->pDataUnit->pPut,pHumanPlayer->vParamPlayer.vTimerGetElapsed);
						fActionGoTo(pHumanPlayer->pDataUnit,pHumanPlayer->vParamPlayer.vTimerGetElapsed);
						pHumanPlayer->vCheck = fCheckGoDataUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
						pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->pDataUnit->WhichUnit);
						if (pHumanPlayer->vCheck == 0 && pHumanPlayer->vIdOrder != ID_ORDER_BLINK && pHumanPlayer->vIdOrder != ID_ORDER_MOVE)
						{
							//StoreInteger(vSyncCache,pDataUnit->vKeyUnit,"vCheck",0);
							//StoreReal(vSyncCache,pDataUnit->vKeyUnit,"vTimerGetElapsedGoTo",0);
							//StoreInteger(vSyncCache,pDataUnit->vKeyUnit,"vActionN",0);
							if (pHumanPlayer->pDataUnit->vHelping == TRUE &&
								//pHumanPlayer->pDataUnit->vInt3 != pHumanPlayer->pDataUnit->vIntForGoTo &&
								pHumanPlayer->pDataUnit->pPut->vCountBlink > 1 &&
								fRemoteness(pHumanPlayer->pDataUnit) == 0)
							{
								pHumanPlayer->pDataUnit->vLastAction = pHumanPlayer->pDataUnit->vAction;
								//fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
								pHumanPlayer->pDataUnit->vSyncClean = TRUE;
								pHumanPlayer->pDataUnit->vAction = ACTION_BLINK;
								pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
								pHumanPlayer->pDataUnit->vIntForGoTo = pHumanPlayer->pDataUnit->vInt3;
							}
							else
							{
								pHumanPlayer->pDataUnit->vLastAction = pHumanPlayer->pDataUnit->vAction;
								fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
							}
							break;
							//pDataUnit->vActionFinish = 1;
							//pDataUnit->vAction = ACTION_WAITING;
							//pDataUnit->vActionN = 0;
							//pDataUnit->vCountActions = 0;
						}

						/*if (pHumanPlayer->pDataUnit->vAction == ACTION_BLINK &&
							fIsMainHuman(pHumanPlayer->pDataUnit->vId) == TRUE)
						{
							pHumanPlayer->vMana = GetUnitState(pHumanPlayer->pDataUnit->WhichUnit, UNIT_STATE_MANA);
							if ((unsigned int)pHumanPlayer->vMana <= 0)
							{
								pHumanPlayer->pDataUnit->vAction = ACTION_GO;
								pHumanPlayer->pDataUnit->vActionN = 0;//ACTION_N_NEW;
								pHumanPlayer->pDataUnit->vCountActions = 0;
								break;
							}
						}*/
						
						pHumanPlayer->vMana = GetUnitState(pHumanPlayer->pDataUnit->WhichUnit, UNIT_STATE_MANA);
						if (pHumanPlayer->vCheck == -1 ||
							(pHumanPlayer->pDataUnit->vTimeGo != 0 &&
							(pHumanPlayer->vParamPlayer.vTimerGetElapsed - pHumanPlayer->pDataUnit->vTimeGo > 5)) ||
							(pHumanPlayer->vCheck == 1 &&
							pHumanPlayer->vIdOrder == 0 &&
							pHumanPlayer->pDataUnit->vInt3 == pHumanPlayer->pDataUnit->vIntForGoTo &&
							//(pHumanPlayer->vActionStackForUnits.pParamPlayer->vTimerGetElapsed - pHumanPlayer->pDataUnit->vTimeGoTo > 5)))
							((unsigned int)pHumanPlayer->vMana < 1)) ||
							((pHumanPlayer->vIdOrder == ID_ORDER_WAITING ||
							pHumanPlayer->vIdOrder == ID_ORDER_BLINK ||
							pHumanPlayer->vIdOrder == ID_ORDER_MOVE) &&
							pHumanPlayer->pDataUnit->vInt3 == pHumanPlayer->pDataUnit->vIntForGoTo &&
							(unsigned int)pHumanPlayer->vMana >= 1))
						{
							if (pHumanPlayer->pDataUnit->vHelping == TRUE &&
								//pHumanPlayer->pDataUnit->vInt3 != pHumanPlayer->pDataUnit->vIntForGoTo &&
								pHumanPlayer->pDataUnit->pPut->vCountBlink > 1 &&
								fRemoteness(pHumanPlayer->pDataUnit) == 0 &&
								fIsMainHuman(pHumanPlayer->pDataUnit->vId) == TRUE)
							{
								pHumanPlayer->pDataUnit->vLastAction = pHumanPlayer->pDataUnit->vAction;
								//fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
								pHumanPlayer->pDataUnit->vSyncClean = TRUE;
								pHumanPlayer->pDataUnit->vAction = ACTION_BLINK;
								pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
								pHumanPlayer->pDataUnit->vIntForGoTo = pHumanPlayer->pDataUnit->vInt3;
								break;
							}
							pHumanPlayer->pDataUnit->vTimeGo = 0;
							//StoreInteger(vSyncCache,pDataUnit->vKeyUnit,"vCheck",0);
							//StoreReal(vSyncCache,pDataUnit->vKeyUnit,"vTimerGetElapsedGoTo",0);
							//StoreInteger(vSyncCache,pDataUnit->vKeyUnit,"vActionN",0);
							//pDataUnit->vAction = ACTION_WAITING;
							if (pHumanPlayer->pDataUnit->Blinked == TRUE &&
								pHumanPlayer->pDataUnit->vAction == ACTION_BLINK &&
								fIsMainHuman(pHumanPlayer->pDataUnit->vId) == TRUE)
							{
								if ((unsigned int)pHumanPlayer->vMana < 1)
								{
									//pHumanPlayer->pDataUnit->vAction = ACTION_GO;
									//pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
									pHumanPlayer->pDataUnit->vCountActions = 0;
									pHumanPlayer->pDataUnit->pPut->vRect5.vX1 = fConvertIToX(pHumanPlayer->pDataUnit->pPut->vInt3);
									pHumanPlayer->pDataUnit->pPut->vRect5.vY1 = fConvertIToY(pHumanPlayer->pDataUnit->pPut->vInt3);
									pHumanPlayer->pDataUnit->pPut->vRect5.vX2 = pHumanPlayer->pDataUnit->pPut->vRect5.vX1 + pHumanPlayer->pDataUnit->pPut->vDiff - 1;
									pHumanPlayer->pDataUnit->pPut->vRect5.vY2 = pHumanPlayer->pDataUnit->pPut->vRect5.vY1 + pHumanPlayer->pDataUnit->pPut->vDiff - 1;
									pHumanPlayer->vG = fG(fConverterIX2RX(pHumanPlayer->pDataUnit->pPut->vRect4.vX1),
														  fConverterIY2RY(pHumanPlayer->pDataUnit->pPut->vRect4.vY1),
														  fConverterIX2RX(pHumanPlayer->pDataUnit->pPut->vRect5.vX2),
														  fConverterIY2RY(pHumanPlayer->pDataUnit->pPut->vRect5.vY2));
									if (pHumanPlayer->vG < 200 || pHumanPlayer->vG > 2500)
									{
										fIssuePointOrderToRect(pHumanPlayer->pDataUnit->WhichUnit,
															   "move",
															   &pHumanPlayer->pDataUnit->pPut->vRect5,
															   pHumanPlayer->pDataUnit->pPut->vRadius_Unit);
									//pHumanPlayer->pDataUnit->vActionFinish = 0;
									//pHumanPlayer->pDataUnit->vAction = ACTION_BLINK;
									//pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
										pHumanPlayer->pDataUnit->vActionN++;
										pHumanPlayer->pDataUnit->vAction = ACTION_GO;
									/*if (pHumanPlayer->pDataUnit->pPut->hTrigger > 0)
									{
										fFreeTrigger(pHumanPlayer->pDataUnit->pPut->hTrigger);
										pHumanPlayer->pDataUnit->pPut->hTrigger = NULL;
									}*/
									//fLog(1,"1");
									//if (pHumanPlayer->pDataUnit->pPut->hTimer > 0)
									//{
									//	DestroyTimer(pHumanPlayer->pDataUnit->pPut->hTimer);
									//}
									//pHumanPlayer->pDataUnit->pPut->hTimer = NULL;
										break;
									}
									//else if (pHumanPlayer->vG > 800)
									//{
									//	pHumanPlayer->pDataUnit->vActionN++;
									//	pHumanPlayer->pDataUnit->vAction = ACTION_GO;
									//	break;
									//}
									else
									{
										pHumanPlayer->pDataUnit->pPut->vInt3 = fJumpBack(pHumanPlayer->vParamPlayer.vUnit[COMMENT_MAIN_HUMAN].pDataUnit);
										pHumanPlayer->pDataUnit->pPut->vRect6.vX1 = fConvertIToX(pHumanPlayer->pDataUnit->pPut->vInt3);
										pHumanPlayer->pDataUnit->pPut->vRect6.vY1 = fConvertIToY(pHumanPlayer->pDataUnit->pPut->vInt3);
										pHumanPlayer->pDataUnit->pPut->vRect6.vX2 = pHumanPlayer->pDataUnit->pPut->vRect5.vX1 + pHumanPlayer->pDataUnit->pPut->vDiff - 1;
										pHumanPlayer->pDataUnit->pPut->vRect6.vY2 = pHumanPlayer->pDataUnit->pPut->vRect5.vY1 + pHumanPlayer->pDataUnit->pPut->vDiff - 1;
										fIssuePointOrderToRect(pHumanPlayer->pDataUnit->WhichUnit,
															   "move",
															   &pHumanPlayer->pDataUnit->pPut->vRect6,
															   pHumanPlayer->pDataUnit->pPut->vRadius_Unit);
										
										pHumanPlayer->pDataUnit->vActionN++;
										pHumanPlayer->pDataUnit->vAction = ACTION_GO;
										break;
									}
								}
							}
							if (pHumanPlayer->pDataUnit->Blinked == TRUE)
							{
								pHumanPlayer->pDataUnit->vAction = ACTION_BLINK;
								//if (pHumanPlayer->pDataUnit->vAction == ACTION_GO)
								//{
								//	pHumanPlayer->pDataUnit->vAction = ACTION_BLINK;
								//}
								//else if (pHumanPlayer->pDataUnit->vAction == ACTION_BLINK)
								//{
								//	pHumanPlayer->pDataUnit->vAction = ACTION_GO;
								//}
							}
							else
							{
								pHumanPlayer->pDataUnit->vAction = ACTION_GO;
							}
							pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
							pHumanPlayer->pDataUnit->vCountActions = 0;
							pHumanPlayer->pDataUnit->vSyncClean = TRUE;
							//pDataUnit->pPut->IdetPoPuti = TRUE;
						}
						//if (0)
						//{
							//fFinishActionUnit(pDataUnit->vIdDataUnit);
						//}
						break;
					case 3:
						pHumanPlayer->pDataUnit->pPut->vRect4.vX1 = fConverterX(GetUnitX(pHumanPlayer->pDataUnit->pPut->vUnit)-pHumanPlayer->pDataUnit->pPut->vRadius_Unit+(float)DOOD_MAP_SUBDIV/4);
						pHumanPlayer->pDataUnit->pPut->vRect4.vY1 = fConverterY(GetUnitY(pHumanPlayer->pDataUnit->pPut->vUnit)+pHumanPlayer->pDataUnit->pPut->vRadius_Unit-(float)DOOD_MAP_SUBDIV/4);
						pHumanPlayer->pDataUnit->pPut->vRect4.vX2 = pHumanPlayer->pDataUnit->pPut->vRect4.vX1 + pHumanPlayer->pDataUnit->pPut->vDiff - 1;
						pHumanPlayer->pDataUnit->pPut->vRect4.vY2 = pHumanPlayer->pDataUnit->pPut->vRect4.vY1 + pHumanPlayer->pDataUnit->pPut->vDiff - 1;
						if (fIsRectToRect(&pHumanPlayer->pDataUnit->pPut->vRect4,&pHumanPlayer->pDataUnit->pPut->vRect5) == TRUE)
						{
							pHumanPlayer->pDataUnit->vLastAction = pHumanPlayer->pDataUnit->vAction;
							fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
							break;
						}
						pHumanPlayer->vMana = GetUnitState(pHumanPlayer->pDataUnit->WhichUnit, UNIT_STATE_MANA);
						if ((unsigned int)pHumanPlayer->vMana >= 1)
						{
							IssueImmediateOrderById(pHumanPlayer->pDataUnit->WhichUnit,ID_ORDER_STOP);
							pHumanPlayer->pDataUnit->vActionFinish = 0;
							pHumanPlayer->pDataUnit->vAction = ACTION_BLINK;
							pHumanPlayer->pDataUnit->vActionN = ACTION_N_NEW;
							pHumanPlayer->pDataUnit->vCountActions = 0;
							pHumanPlayer->pDataUnit->vSyncClean = TRUE;
							break;
						}
										if (vMapBases.fRemotenessBase(fConverterIX2RX(pHumanPlayer->pDataUnit->vRect1.vX1),fConverterIY2RY(pHumanPlayer->pDataUnit->vRect1.vY1)) <= 0 &&
											pHumanPlayer->pDataUnit->vHelpBase &&
											(vDataUnits[10 + 0].pDataUnit == NULL || (vDataUnits[10 + 0].pDataUnit &&
											 pHumanPlayer->pDataUnit->vHelpBase->vWallCreated == TRUE &&
											 IsUnitVisible(vDataUnits[10 + 0].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
											 fG(vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X,
											 vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y,
											 fConverterIX2RX(pHumanPlayer->pDataUnit->vRect1.vX1),
											 fConverterIY2RY(pHumanPlayer->pDataUnit->vRect1.vY1)) < (128 * 8))) &&
											 (vDataUnits[10 + 1].pDataUnit == NULL || (vDataUnits[10 + 1].pDataUnit &&
											 pHumanPlayer->pDataUnit->vHelpBase->vWallCreated == TRUE &&
											 IsUnitVisible(vDataUnits[10 + 1].pDataUnit->WhichUnit,pHumanPlayer->vParamPlayer.vPlayer) == TRUE &&
											 fG(vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X,
											 vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y,
											 fConverterIX2RX(pHumanPlayer->pDataUnit->vRect1.vX1),
											 fConverterIY2RY(pHumanPlayer->pDataUnit->vRect1.vY1)) < (128 * 8))))
										{
											pHumanPlayer->vX_1 = fConverterIX2RX(pHumanPlayer->pDataUnit->vRect1.vX1);
											pHumanPlayer->vY_1 = fConverterIY2RY(pHumanPlayer->pDataUnit->vRect1.vY1);
											pHumanPlayer->vG = 0;
											pHumanPlayer->vG2 = 0;
											if (vDataUnits[10 + 0].pDataUnit)
											{
												pHumanPlayer->vG = fG(vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X,
																	 vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y,
																	 fConverterIX2RX(pHumanPlayer->pDataUnit->vRect1.vX1),
																	 fConverterIY2RY(pHumanPlayer->pDataUnit->vRect1.vY1));
											}
											if (vDataUnits[10 + 1].pDataUnit)
											{
												pHumanPlayer->vG2 = fG(vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X,
																	 vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y,
																	 fConverterIX2RX(pHumanPlayer->pDataUnit->vRect1.vX1),
																	 fConverterIY2RY(pHumanPlayer->pDataUnit->vRect1.vY1));
											}
											if (vDataUnits[10 + 0].pDataUnit &&
												(pHumanPlayer->vG < pHumanPlayer->vG2 || pHumanPlayer->vG2 == 0))
											{
												pHumanPlayer->vX_2 = vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.X;
												pHumanPlayer->vY_2 = vDataUnits[10 + 0].pDataUnit->LastCoordinatesForEnemy.Y;
												
											}
											else if (vDataUnits[10 + 1].pDataUnit &&
												(pHumanPlayer->vG >= pHumanPlayer->vG2 || pHumanPlayer->vG == 0))
											{
												pHumanPlayer->vX_2 = vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.X;
												pHumanPlayer->vY_2 = vDataUnits[10 + 1].pDataUnit->LastCoordinatesForEnemy.Y;
											}
											pHumanPlayer->vX_1 = pHumanPlayer->vX_1 + abs(pHumanPlayer->vX_2 - pHumanPlayer->vX_1) / 16 *
												(pHumanPlayer->vX_1 >= pHumanPlayer->vX_2 ? 1 : -1);
											pHumanPlayer->vY_1 = pHumanPlayer->vY_1 + abs(pHumanPlayer->vY_2 - pHumanPlayer->vY_1) / 16 *
												(pHumanPlayer->vY_1 >= pHumanPlayer->vY_2 ? -1 : 1);
											IssuePointOrder(pHumanPlayer->pDataUnit->WhichUnit,
															"move",
															pHumanPlayer->vX_1,
															pHumanPlayer->vY_1);
											break;
										}
						break;
					}
					break;
				case ACTION_TELEPORT:
					break;
				case ACTION_BUILD:
					switch(pHumanPlayer->pDataUnit->vActionN)
					{
					case 0:
						pHumanPlayer->vCheck = 0;
						if (GetUnitTypeId(pHumanPlayer->pDataUnit->WhichUnit) == 0)
						{
							fAddDataUnitInRange(pHumanPlayer,pHumanPlayer->pDataUnit);
							break;
						}
						pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->pDataUnit->WhichUnit);
						/*sprintf(vTest,"vIdOrder = %d",vIdOrder );
						DisplayTextToPlayer( GetLocalPlayer(), 0.0, 0.0, vTest );
						sprintf(vTest,"OrderId(build) = %d",OrderId("build") );
						DisplayTextToPlayer( GetLocalPlayer(), 0.0, 0.0, vTest );*/
						if (pHumanPlayer->vIdOrder == 0 ||
							pHumanPlayer->vIdOrder == pHumanPlayer->pDataUnit->vIdBuild ||
							pHumanPlayer->vIdOrder == ID_ORDER_MOVE)
							pHumanPlayer->vCheck = 1;//OrderId("build")) vCheck = 1;
						if (pHumanPlayer->vCheck == 1)
						{
							pHumanPlayer->pDataUnit->vLastAction = pHumanPlayer->pDataUnit->vAction;
							fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
							//pDataUnit->vActionFinish = 1;
							//pDataUnit->vAction = ACTION_WAITING;
							//pDataUnit->vActionN = 0;
							//pDataUnit->vCountActions = 0;
							break;
						}
						break;
					}
					break;
				case ACTION_ATTACK:
					switch(pHumanPlayer->pDataUnit->vActionN)
					{
					case 0:
						pHumanPlayer->vCheck = 0;
						pHumanPlayer->vIdOrder = GetUnitCurrentOrder(pHumanPlayer->pDataUnit->WhichUnit);
						if (pHumanPlayer->vIdOrder == 0 || pHumanPlayer->vIdOrder == ID_ORDER_MOVE) pHumanPlayer->vCheck = 1;
						if (pHumanPlayer->vCheck == 1)
						{
							pHumanPlayer->pDataUnit->vLastAction = pHumanPlayer->pDataUnit->vAction;
							fFinishActionUnit(pHumanPlayer->pDataUnit->vIdDataUnit);
							break;
						}
						break;
					}
					break;
				}
			}
		}
		current = current->next;
	}
}

unsigned short fTrainAction(HumanPlayer *pHumanPlayer, unsigned short vComment, integer vIdDataUnitTrain, unsigned short vCount)
{
	if (vIdDataUnitTrain <= 0) return 0;
	DataUnit *pDataUnit;
	unsigned short vFlag = 0;
	pDataUnit = pHumanPlayer->vActionStackForUnits.fGetDataUnit(vComment);
	if (pDataUnit && (unsigned int)pDataUnit != 0xdddddddd)
	{
		if (pDataUnit->Postroeno == TRUE || fCompliteBuild(pDataUnit,pHumanPlayer->vParamPlayer.vTimerGetElapsed) == TRUE)
		{
			//fGetLastCoordinates(pDataUnit);
			for (unsigned short vvi = 0; vvi < vCount; vvi++)
			{
				if (fIsEnoughResourses(pHumanPlayer->vParamPlayer.vPlayer,vIdDataUnitTrain) == TRUE)
				{
					if (IssueImmediateOrderById(pDataUnit->WhichUnit,vIdDataUnitTrain) == TRUE)
					{
						vFlag = 1;
					}
					else
					{
						fAddDataUnitInRange(pHumanPlayer,pDataUnit);
					}
				}
			}
			return vFlag;
		}
		else
		{
			pDataUnit->fGetPostroeno();
		}
	}
	return vFlag;
}

/*unsigned short fTrainActionResearch(HumanPlayer *pHumanPlayer, DataUnit *pDataUnit, integer vNResearch)
{
	integer vId; 
	unsigned short vFlag = 0;
	if (pDataUnit && (unsigned int)pDataUnit != 0xdddddddd)
	{
		if (pDataUnit->Postroeno == TRUE)
		{
			if (fIsEnoughResourses(pHumanPlayer->vParamPlayer.vPlayer,&pHumanPlayer->vParamPlayer,vNResearch,&vId) == TRUE)
			{
				fAddDataUnitInRange(pHumanPlayer,pDataUnit);
				if(IssueImmediateOrderById(pDataUnit->WhichUnit,vId) == TRUE)
				{
					pDataUnit->vNResearch = vNResearch;
					vFlag = 1;
				}
			}
			return vFlag;
		}
	}
	return vFlag;
}*/