#include "stdafx.h"
#include "Global_variables_extern.h"
#include "Basics_functions.h"
#include "Vampirism_fire.h"
#include "DB_Cost.h"
#include "VampireTactics.h"

bool fBreezeToUnit(VampirePlayer *pVampirePlayer, sUnitParam *vUnitParam, DataUnit *pDataUnit, real vTimer, bool vFlagBreeze)
{
	if (vUnitParam == NULL || pDataUnit == NULL) return FALSE;
	if (vUnitParam->pDataUnits->pDataUnit == NULL) return FALSE;
	if (vUnitParam->vRetreat == TRUE) return FALSE;
				pVampirePlayer->vIdOrder = GetUnitCurrentOrder(vUnitParam->pDataUnits->pDataUnit->WhichUnit);
				pVampirePlayer->vTime = pVampirePlayer->vParamPlayer.vTimerGetElapsed - vTimer;
				if (vFlagBreeze == FALSE)
				{
					pVampirePlayer->vTime2 = 4.8;
				}
				else
				{
					pVampirePlayer->vTime2 = 4.7;
				}
				if (vUnitParam->pDataUnits->pDataUnit->Atakuet == FALSE &&
					pVampirePlayer->vIdOrder == ID_ORDER_MOVE &&
					((pVampirePlayer->vVampire.vUnitParam.pDataUnits->vId == vUnitParam->pDataUnits->vId &&
					(pVampirePlayer->vTime < pVampirePlayer->vTime2)) ||
					(pVampirePlayer->vVampire.vUnitParam.pDataUnits->vId != vUnitParam->pDataUnits->vId &&
					(pVampirePlayer->vTime < (pVampirePlayer->vTime2)))))
				{
					goto m1;
				}
				if ((pVampirePlayer->vIdOrder == ID_ORDER_WAITING ||
					pVampirePlayer->vIdOrder == ID_ORDER_ATTACK) &&
					((pVampirePlayer->vVampire.vUnitParam.pDataUnits->vId == vUnitParam->pDataUnits->vId &&
					pVampirePlayer->vIdOrder != ID_ORDER_HEALINGWAVE &&
					(pVampirePlayer->vTime < pVampirePlayer->vTime2)) ||
					(pVampirePlayer->vVampire.vUnitParam.pDataUnits->vId != vUnitParam->pDataUnits->vId &&
					(pVampirePlayer->vTime < (pVampirePlayer->vTime2)))))
				{
					if (IssuePointOrderById(vUnitParam->pDataUnits->pDataUnit->WhichUnit,
											ID_ORDER_MOVE,
											GetUnitX(pDataUnit->WhichUnit),
											GetUnitY(pDataUnit->WhichUnit)) == TRUE)
					{
						vUnitParam->pDataUnits->pDataUnit->Atakuet = FALSE;
						vUnitParam->pDataUnits->pDataUnit->vGoToGlobal = TRUE;
						goto m1;
					}
					else
					{
						vUnitParam->pDataUnits->pDataUnit->TargetUnit = NULL;
					}
				}
				if (pVampirePlayer->vIdOrder != ID_ORDER_ATTACK ||
					(vUnitParam->pDataUnits->pDataUnit->TargetUnit != pDataUnit->WhichUnit))
				{
					if (IssueTargetOrderById(vUnitParam->pDataUnits->pDataUnit->WhichUnit,
											 ID_ORDER_ATTACK,
											 pDataUnit->WhichUnit) == TRUE)
					{
						
						pVampirePlayer->vHealingwave = FALSE;
						vUnitParam->pDataUnits->pDataUnit->vGoToGlobal = TRUE;
						goto m1;
					}
					else
					{
						vUnitParam->pDataUnits->pDataUnit->TargetUnit = NULL;
					}
				}
m1:;
	return TRUE;
}

void fBreeze()
{
	HTIMER t = GetExpiredTimer();
	VampirePlayer *pVampirePlayer;
	pVampirePlayer = NULL;
	pVampirePlayer = (VampirePlayer *)LoadInteger(vHT,t,CONST_AI_PLAYER_BREEZE);
	if (pVampirePlayer == NULL)
	{
		if (t > 0)
		{
			DestroyTimer(t);
		}
		return;
	}
	if ((pDataVampires->vFlagBreeze == TRUE &&
		pVampirePlayer->vCountForTimerBreeze >= 20) ||
		(pDataVampires->vFlagBreeze == FALSE &&
		pVampirePlayer->vCountForTimerBreeze >= 10))
	{
		pDataVampires->vFlagBreeze = FALSE;
		goto m2;
	}
	if ((pDataVampires->vFlagBreeze == TRUE &&
		pVampirePlayer->vCountForTimerBreeze < 0) ||
		(pDataVampires->vFlagBreeze == FALSE &&
		pVampirePlayer->vCountForTimerBreeze < 0))
	{
		goto m1;
	}
	if (pVampirePlayer->u == 0) goto m2;
	if (pDataVampires->vFlagBreeze == FALSE ||
		(pDataVampires->vFlagBreeze == TRUE &&
		(GetUnitState(pVampirePlayer->u, UNIT_STATE_LIFE) <=
		(GetUnitState(pVampirePlayer->u, UNIT_STATE_MAX_LIFE) * 0.43))))
	{
								pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = TRUE;
								if (UnitUseItemTarget(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
													  pVampirePlayer->vVampire.vInventory.fGetItem(ID_ITEM_BREEZE),
													  pVampirePlayer->u) == TRUE)
								{
									pVampirePlayer->vVampire.vInventory.fRefreshInventory();
									if (pVampirePlayer->vQItems != pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_BREEZE))
									{
										for (pVampirePlayer->vvi; pVampirePlayer->vvi < 2; pVampirePlayer->vvi++)
										{
											if ((unsigned int)pVampirePlayer->pPartner->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits != 0xcdcdcdcd &&
												pVampirePlayer->pPartner->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits != NULL)
											{
												pVampirePlayer->pPartner->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit = pVampirePlayer->u;
												pVampirePlayer->pPartner->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->Atakuet = FALSE;
												IssueImmediateOrderById(pVampirePlayer->pPartner->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,0);
											}
										}
										pDataVampires->vMainHumanBreeze = pVampirePlayer->pDataUnit;
										pDataVampires->vTimerMainHumanBreeze = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
										pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit = pVampirePlayer->u;
										pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit = pVampirePlayer->u;
										pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Atakuet = FALSE;
										pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->Atakuet = FALSE;
										pVampirePlayer->vHealingwave = TRUE;
										pVampirePlayer->pPartner->vHealingwave = TRUE;
										pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
										if (pDataVampires->vFlagBreeze == FALSE)
										{
											pDataVampires->vFlagBreeze = TRUE;
										}
										else
										{
											pDataVampires->vMainHumanBreeze = NULL;
											pDataVampires->vFlagBreeze = FALSE;
										}
										goto m2;
									}
								}
								pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
	}
m1:
	pVampirePlayer->vCountForTimerBreeze++;
	if (0)
	{
m2:
								SaveInteger(vHT,pVampirePlayer->vTimerBreeze,CONST_AI_PLAYER_BREEZE,0);
								if (pVampirePlayer->vTimerBreeze > 0)
								{
									DestroyTimer(pVampirePlayer->vTimerBreeze);
								}
								pVampirePlayer->vTimerBreeze = NULL;
	}
}

bool fZeroBaseBreeze(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
	if (pVampirePlayer->vTimerBreeze != NULL) goto m1;
	// Ветерки юзаем на нулевую базу, если партнёр рядом и 2 тиника рядом при начальной стадии игры и 1 тиник при дальнейшей стадии игры
				pVampirePlayer->vQItems = pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_BREEZE);
				if (pVampirePlayer->pPartner != NULL &&
					pDataVampires->vTimerMainHumanBreeze == 0 &&
					pVampirePlayer->vQItems > 0 &&
					(((unsigned int)pVampirePlayer->pPartner->vMassTini[0].vUnitParam.pDataUnits != 0xcdcdcdcd &&
					pVampirePlayer->pPartner->vMassTini[0].vUnitParam.pDataUnits != NULL &&
					(unsigned int)pVampirePlayer->pPartner->vMassTini[1].vUnitParam.pDataUnits != 0xcdcdcdcd &&
					pVampirePlayer->pPartner->vMassTini[1].vUnitParam.pDataUnits != NULL) ||
					(pVampirePlayer->vParamPlayer.vTimerGetElapsed > 60 * 3)))
				{
					pVampirePlayer->hGroupFarm = CreateGroup();
					GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
										  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
										  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
										  128*6,Filter(&fFilterMainHuman));
					pVampirePlayer->u = fGetNearestUnitEnemy(pVampirePlayer->hGroupFarm,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,TRUE);
					DestroyGroup(pVampirePlayer->hGroupFarm);
					//do
					//{
						//pVampirePlayer->u = FirstOfGroup(pVampirePlayer->hGroupFarm);
						if (pVampirePlayer->u != 0)
						{
							if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vGoTo == TRUE && pDataVampires->vFlagBreeze == FALSE)
							{
								if (pVampirePlayer->vTimeTestGoTo == 0)
								{
									goto m16;
								}
								if ((pVampirePlayer->vParamPlayer.vTimerGetElapsed > pVampirePlayer->vTimeTestGoTo) &&
									pVampirePlayer->vTimeTestGoTo != 0)
								{
									if(fCheckGoTo(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vIdDataUnit) != 1)
									{
										if (pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeTestGoTo > 1)
										{
											pVampirePlayer->vTimeTestGoTo = 0;
										}
										goto m14;
									}
									else
									{
										pVampirePlayer->vTimeTestGoTo = 0;
										goto m15;
									}
								}
							}
m16:
							if (fUnitGoToInt(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vIdDataUnit,
								             fConvertXYToI(fConverterX(GetUnitX(pVampirePlayer->u)),fConverterY(GetUnitY(pVampirePlayer->u))),
										     ACTION_GO,
										     LIMIT_BREEZE_VAMPIRE) == 1)
								pVampirePlayer->vTimeTestGoTo = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
							goto m14;
m15:
							pVampirePlayer->hGroupFarm = CreateGroup();
							GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
												  GetUnitX(pVampirePlayer->u),
												  GetUnitY(pVampirePlayer->u),
												  128*2,Filter(&fFilterWall));
							pVampirePlayer->u2 = fGetNearestUnitEnemy(pVampirePlayer->hGroupFarm,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,TRUE);
							DestroyGroup(pVampirePlayer->hGroupFarm);
							if (pVampirePlayer->u2 != NULL) goto m14;
							pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->u);
							pVampirePlayer->pDataUnit = fGetDataUnit(pVampirePlayer->u);
							pVampirePlayer->vX_2 = GetUnitX(pVampirePlayer->u);
							pVampirePlayer->vY_2 = GetUnitY(pVampirePlayer->u);
							if (fIsMainHuman(pVampirePlayer->vId) == TRUE &&
								fFindBaseByDataUnit(pVampirePlayer->pDataUnit) == 0 &&
								((pVampirePlayer->pPartner != NULL &&
								fG(pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
								   pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
								   pVampirePlayer->vX_2,
								   pVampirePlayer->vY_2) < 128*8 &&
								(unsigned int)pVampirePlayer->pPartner->vMassTini[0].vUnitParam.pDataUnits != 0xcdcdcdcd &&
								pVampirePlayer->pPartner->vMassTini[0].vUnitParam.pDataUnits != NULL &&
								pVampirePlayer->pPartner->vMassTini[0].vUnitParam.pDataUnits->pDataUnit != NULL &&
								fG(pVampirePlayer->pPartner->vMassTini[0].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
								   pVampirePlayer->pPartner->vMassTini[0].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
								   pVampirePlayer->vX_2,
								   pVampirePlayer->vY_2) < 128*8 &&
								(unsigned int)pVampirePlayer->pPartner->vMassTini[1].vUnitParam.pDataUnits != 0xcdcdcdcd &&
								pVampirePlayer->pPartner->vMassTini[1].vUnitParam.pDataUnits != NULL &&
								pVampirePlayer->pPartner->vMassTini[1].vUnitParam.pDataUnits->pDataUnit != NULL &&
								fG(pVampirePlayer->pPartner->vMassTini[1].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
								   pVampirePlayer->pPartner->vMassTini[1].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
								   pVampirePlayer->vX_2,
								   pVampirePlayer->vY_2) < 128*8) ||
								   (pVampirePlayer->vParamPlayer.vTimerGetElapsed > 60 * 3)))
							{	
								pVampirePlayer->vTimerBreeze = CreateTimer();
								SaveInteger(vHT,pVampirePlayer->vTimerBreeze,CONST_AI_PLAYER_BREEZE,(integer)pVampirePlayer);
								pVampirePlayer->vCountForTimerBreeze = 0;
								TimerStart(pVampirePlayer->vTimerBreeze,0.01,true,&fBreeze);
								goto m1;
							}
m14:;
						}
				}
	return FALSE;
m1:;
	return TRUE;
}

bool fVampireTactics2(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
	if (pVampirePlayer->vVampire.vUnitParam.vRetreat == TRUE) return FALSE;
	if (pVampirePlayer->vFarmBase != DO_NOT_FIND_BASE &&
		pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE)
	{
		if (pDataVampires->vMainHumanBreeze != NULL)
		{
			pVampirePlayer->pDataUnit = fGetDataUnit(pDataVampires->vMainHumanBreeze->WhichUnit);
			if (pDataVampires->vTimerMainHumanBreeze != 0 &&
				(pVampirePlayer->pDataUnit == NULL ||
				(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pDataVampires->vTimerMainHumanBreeze > 8)))
			{
				pDataVampires->vMainHumanBreeze = NULL;
				pDataVampires->vTimerMainHumanBreeze = 0;
				pDataVampires->vFlagBreeze = FALSE;
				pVampirePlayer->vHealingwave = TRUE;
				if (pVampirePlayer->pPartner != NULL) pVampirePlayer->pPartner->vHealingwave = TRUE;
			}
			else if (pVampirePlayer->pDataUnit != NULL)
			{
				if (fBreezeToUnit(pVampirePlayer,
								  &pVampirePlayer->vVampire.vUnitParam,
								  pDataVampires->vMainHumanBreeze,
								  pDataVampires->vTimerMainHumanBreeze,
								  pDataVampires->vFlagBreeze) == TRUE)
				{
					if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Atakuet == TRUE ||
						(pVampirePlayer->pPartner != NULL &&
						pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->Atakuet == TRUE))
					{
						//pDataVampires->vTimerMainHumanBreeze = 0;
						if (pVampirePlayer->vParamPlayer.vAI == 10)
						{
							if (fZeroBaseBreeze(pVampirePlayer) == TRUE) goto m1;
						}
						else
						{
							if (pVampirePlayer->pPartner!= NULL &&
								fZeroBaseBreeze(pVampirePlayer->pPartner) == TRUE) goto m1;
						}
					}
					else
					{
						goto m1;
					}
				}
			}
		}
		if (pVampirePlayer->vStealthON == FALSE || (pVampirePlayer->vStealthON == TRUE && pVampirePlayer->fStealthOff() == TRUE))
		{
			pVampirePlayer->pDataUnit = fGetDataUnit(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit);
			if (pVampirePlayer->pDataUnit == NULL)
			{
				pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit = NULL;
			}
			if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit != 0)
			{
				// Ветерки юзаем на нулевую базу, если партнёр рядом и 2 тиника рядом при начальной стадии игры и 1 тиник при дальнейшей стадии игры
				if (fZeroBaseBreeze(pVampirePlayer) == TRUE) goto m1;
				// Берём vId таргета
				pVampirePlayer->vId = 0;
				if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit != NULL)
				{
					pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit);
				}
				// Если таргет вал
				if (fIsWall(pVampirePlayer->vId) == TRUE)
				{
					// Отступаем, если вал хорошо ремонтируют
					if (pDataVampires->vTiniGo == FALSE &&
						(pDataVampires->vTimeAttackWall == 0 ||
						(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pDataVampires->vTimeAttackWall > 3)))
					{
						pDataVampires->vTimeAttackWall = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
						pVampirePlayer->vProcHPWall = GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit, UNIT_STATE_LIFE)/
													  GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit, UNIT_STATE_MAX_LIFE);
						if (pDataVampires->vLastProcHPWall != 0 &&
							pVampirePlayer->vProcHPWall != 1 &&
							(pDataVampires->vLastProcHPWall - pVampirePlayer->vProcHPWall <= 0))
						{
							pDataVampires->vLastProcHPWall = 0;
							/*pDataVampires->vFalgNextBase = TRUE;
							pDataVampires->vTimeNextBase = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
							pDataVampires->vTiniGo = FALSE;
							pVampirePlayer->vVampire.vUnitParam.vAttack = FALSE;
							if (pVampirePlayer->pPartner != NULL) pVampirePlayer->pPartner->vVampire.vUnitParam.vAttack = FALSE;
							fEndAttack();*/
							fGoNextBase(pVampirePlayer);
							goto m1;
						}
						else
						{
							pDataVampires->vLastProcHPWall = pVampirePlayer->vProcHPWall;
						}
					}
					if (pDataVampires->vWall == FALSE &&
						pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Atakuet == TRUE)
					{
						pDataVampires->vWall = TRUE;
					}
					// Подвинься вамп
					if (pDataVampires->vTypeBazeOneCell == FALSE &&
						pVampirePlayer->pPartner != NULL &&
						fMoveOver(pVampirePlayer,
								  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
								  pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit) == TRUE)
					{
						goto m1;
					}
					if (pVampirePlayer->vStepBack == TRUE &&
						pVampirePlayer->vTimeStepBack != 0)
					{
						if (pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeStepBack > 3)
						{
							pVampirePlayer->vTimeStepBack = 0;
							pVampirePlayer->vStepBack = FALSE;
						}
						else
						{
							goto m1;
						}
					}
					if (pDataVampires->vTiniGo == TRUE &&
						pVampirePlayer->vStepBack == TRUE &&
						pVampirePlayer->vTimeStepBack == 0 &&
						fStepBack(pVampirePlayer,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit) == TRUE)
					{
						//if (pVampirePlayer->fStealthON() == TRUE);
						pVampirePlayer->vTimeStepBack = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
						goto m1;
					}
					// Перейти на новую базу, если более или равно 4 хумана ченят вал
					if (pDataVampires->vWall == TRUE &&
						pDataVampires->vFalgNextBase == FALSE &&
						pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vTimerRaisingClifLevel < 30)
					{
					// Подсчёт
					pVampirePlayer->hGroupFarm = CreateGroup();
					GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
											pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
											pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
											128*5,Filter(&fFilterMainHuman));
					pVampirePlayer->vQ = 0;
					do
					{
						pVampirePlayer->u = FirstOfGroup(pVampirePlayer->hGroupFarm);
						if (pVampirePlayer->u != 0 &&
							IsUnitEnemy(pVampirePlayer->u,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vPlayer) == TRUE &&
							IsUnitVisible(pVampirePlayer->u,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vPlayer) == TRUE)
						{
							pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->u);
							if (fIsMainHuman(pVampirePlayer->vId) == TRUE)
							{
								pVampirePlayer->vQ++;
							}
						}
						GroupRemoveUnit(pVampirePlayer->hGroupFarm,pVampirePlayer->u);
					}
					while (pVampirePlayer->u != 0);
					DestroyGroup(pVampirePlayer->hGroupFarm);
					pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit);
					if (pVampirePlayer->vQ >= 4 &&
						(pVampirePlayer->vId == ID_UNIT_BUILD_WALL_VIOLET ||
						pVampirePlayer->vId == ID_UNIT_BUILD_WALL_BLUE))
					{
						fGoNextBase(pVampirePlayer);
						goto m1;
					}
					}
					// Ломаем вал
					if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Atakuet == TRUE)
					{
						// Отступаем
						if (pVampirePlayer->vVampire.vUnitParam.vRetreat == FALSE &&
							(GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
							(GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.4)))
						{
							if (fOrderToIdDataUnit(pVampirePlayer,
												   pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
												   ID_ORDER_MOVE,
												   vManaWell) == TRUE)
							{
								pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit = 0;
								pVampirePlayer->vVampire.vUnitParam.vRetreat = TRUE;
								goto m1;
							}
						}
						// Попросить передать бессмертие
						if (pVampirePlayer->pPartner != NULL &&
							pVampirePlayer->pPartner->vInvulnerability == TRUE &&
							pVampirePlayer->vFlagIPassedInvulnerability == FALSE &&
							pVampirePlayer->vInvulnerability == FALSE &&
							pVampirePlayer->vInvulnerability == pVampirePlayer->pPartner->vInvulnerability &&
							pVampirePlayer->vTransmitInvulnerability == FALSE &&
							pVampirePlayer->pPartner->vTransmitInvulnerability == FALSE &&
							pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_IMMORTALITY) == 0 &&
							pVampirePlayer->pPartner->vVampire.vInventory.fQItems(ID_ITEM_IMMORTALITY) >= 1)
						{
							pVampirePlayer->pPartner->vTransmitInvulnerability = TRUE;
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vPickupItem = FALSE;
							pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->vPickupItem = FALSE;
						}
						// Юзаем свиток зверя
						if (pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_BEAST_SCROLL) > 0 &&
							(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeBeastScroll) >= 0)
						{
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = TRUE;
							if (UnitUseItem(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
											pVampirePlayer->vVampire.vInventory.fGetItem(ID_ITEM_BEAST_SCROLL)) == TRUE)
							{
								pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
								pVampirePlayer->vVampire.vInventory.fRefreshInventory();
								pVampirePlayer->vTimeBeastScroll = pVampirePlayer->vParamPlayer.vTimerGetElapsed + 10;
								goto m1;
							}
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
						}
						// Юзаем бессмертие
						if ((pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeInvulnerability) >= 45 &&
							pVampirePlayer->vTransmitInvulnerability == FALSE &&
							GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
							(GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.5))
						{
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = TRUE;
							if (UnitUseItem(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
											pVampirePlayer->vVampire.vInventory.fGetItem(ID_ITEM_IMMORTALITY)) == TRUE)
							{
								pVampirePlayer->vFlagIPassedInvulnerability = FALSE;
								pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
								pVampirePlayer->vTransmitInvulnerability = TRUE;
								pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vPickupItem = FALSE;
								if (pVampirePlayer->pPartner != NULL)
								{
									pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->vPickupItem = FALSE;
								}
								//pVampirePlayer->vTimeAction = pVampirePlayer->vParamPlayer.vTimerGetElapsed + 0.5;
								pVampirePlayer->vTimeInvulnerability = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
								pVampirePlayer->vInvulnerability = TRUE;
								goto m1;
							}
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
						}
						// Юзаем ветерки, если бессмертие использовано
						if (pVampirePlayer->vInvulnerability == TRUE &&
							pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_BREEZE) > 0)
						{
							pVampirePlayer->hGroupFarm = CreateGroup();
							GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
												  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
												  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
												  128*3,Filter(&fFilterMainHuman));
							do
							{
								pVampirePlayer->u = FirstOfGroup(pVampirePlayer->hGroupFarm);
								if (pVampirePlayer->u != 0)
								{
									pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->u);
									if (fIsMainHuman(pVampirePlayer->vId) == TRUE)
									{
										pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = TRUE;
										if (UnitUseItemTarget(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
															  pVampirePlayer->vVampire.vInventory.fGetItem(ID_ITEM_BREEZE),
															  pVampirePlayer->u) == FALSE)
										{
											pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
											pVampirePlayer->vVampire.vInventory.fRefreshInventory();
											DestroyGroup(pVampirePlayer->hGroupFarm);
											goto m1;
										}
										pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
									}
								}
								GroupRemoveUnit(pVampirePlayer->hGroupFarm,pVampirePlayer->u);
							}
							while (pVampirePlayer->u != 0);
							DestroyGroup(pVampirePlayer->hGroupFarm);
						}
					}
					// Атакуем вал по новой
					pVampirePlayer->vIdOrder = GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit);
					if (pVampirePlayer->vVampire.vUnitParam.vRetreat == FALSE &&
						pVampirePlayer->vIdOrder != ID_ORDER_ATTACK &&
						pVampirePlayer->vIdOrder != ID_ORDER_MOVE)
					{
						if (IssueTargetOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
												 ID_ORDER_ATTACK,
												 pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit) == TRUE)
						{
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vGoToGlobal = TRUE;
						}
						else
						{
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit = NULL;
						}
					}
				}
				else if ((pVampirePlayer->pPartner == NULL ||
					     (pVampirePlayer->pPartner != NULL &&
						 pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->Atakuet == FALSE)))
				{
					pDataVampires->vLastProcHPWall = 0;
					pDataVampires->vWall = FALSE;
				}
				// Обнуляем таргет файр инфернала
				if (pVampirePlayer->vFireInfernal != NULL)
				{
					pVampirePlayer->pDataUnit = fGetDataUnit(pVampirePlayer->vFireInfernal->TargetUnit);
					if (pVampirePlayer->pDataUnit == NULL)
					{
						pVampirePlayer->vFireInfernal->TargetUnit = NULL;
					}
				}
				// Если таргет файр инфернала вал, то тини го, если проход в базу не одноклеточный.
				if (pDataVampires->vTiniGo == FALSE &&
					pDataVampires->vTypeBazeOneCell == FALSE &&
					pVampirePlayer->vFireInfernal != NULL &&
					pVampirePlayer->vFireInfernal->TargetUnit != NULL)
				{
					pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vFireInfernal->TargetUnit);
					if (pVampirePlayer->vStepBack == FALSE &&
						pDataVampires->vWall == TRUE &&
						fIsWall(pVampirePlayer->vId) == TRUE)
					{
						pDataVampires->vTiniGo = TRUE;
					}
				}
				// Если есть бесмертие то тини го.
				if ((pVampirePlayer->vInvulnerability == FALSE ||
					(pVampirePlayer->pPartner != NULL &&
					pVampirePlayer->pPartner->vInvulnerability == FALSE)) &&
					(pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_IMMORTALITY) >= 1 ||
					(pVampirePlayer->pPartner != NULL &&
					pVampirePlayer->pPartner->vVampire.vInventory.fQItems(ID_ITEM_IMMORTALITY) >= 1)))
				{
					pDataVampires->vTiniGo = TRUE;
				}
				// Отступаем на 3 клетки, если оба вампира ломают вал и тиники идут вперёд.
				if (pDataVampires->vTiniGo == TRUE &&
					pVampirePlayer->pPartner != NULL &&
					pVampirePlayer->pPartner->vStepBack == FALSE &&
					pVampirePlayer->vStepBack == FALSE)
				{
					pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit);
					if (fIsWall(pVampirePlayer->vId) == TRUE &&
						pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Atakuet == TRUE)
					{
						pVampirePlayer->vStepBack = TRUE;
					}
					pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit);
					if (fIsWall(pVampirePlayer->vId) == TRUE &&
						pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->Atakuet == TRUE)
					{
						pVampirePlayer->pPartner->vStepBack = TRUE;
					}
				}
				
			}
			else if (pVampirePlayer->pPartner != NULL &&
				     pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit == NULL)
			{
				pDataVampires->vWall = FALSE;
			}
m5:
			// Двигаемся меняем цель.
			if (pVampirePlayer->pPartner == NULL ||
				(pVampirePlayer->pPartner != NULL &&
				(pVampirePlayer->vComeToMe == FALSE ||
				(pVampirePlayer->vComeToMe == TRUE &&
				fComeToMe(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit,128*24) == FALSE))))
			{
				if (((unsigned int)pVampirePlayer->vMassTini[0].vUnitParam.pDataUnits != 0xcdcdcdcd &&
					pVampirePlayer->vMassTini[0].vUnitParam.pDataUnits != NULL &&
					pVampirePlayer->vMassTini[0].vUnitParam.pDataUnits->pDataUnit))
				{
					pVampirePlayer->vComeToMeTini = TRUE;
				}
				else
				{
					pVampirePlayer->vComeToMeTini = FALSE;
				}
				if (((unsigned int)pVampirePlayer->vMassInfernal[0].vUnitParam.pDataUnits != 0xcdcdcdcd &&
					pVampirePlayer->vMassInfernal[0].vUnitParam.pDataUnits != NULL &&
					pVampirePlayer->vMassInfernal[0].vUnitParam.pDataUnits->pDataUnit))
				{
					pVampirePlayer->vComeToMeInfernal = TRUE;
				}
				else
				{
					pVampirePlayer->vComeToMeInfernal = FALSE;
				}
				if (pVampirePlayer->pPartner != NULL &&
					pVampirePlayer->vFlagPullYourselfUp == TRUE)
				{
					pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X = pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X;
					pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y = pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y;
			
				}
				if ((pVampirePlayer->pPartner == NULL &&
					pVampirePlayer->vComeToMeTini == FALSE &&
					pVampirePlayer->vComeToMeInfernal == FALSE) ||
					(pVampirePlayer->pPartner != NULL &&
					pVampirePlayer->pPartner->vComeToMeTini == FALSE &&
					pVampirePlayer->pPartner->vComeToMeInfernal == FALSE &&
					pVampirePlayer->vComeToMeTini == FALSE &&
					pVampirePlayer->vComeToMeInfernal == FALSE) ||
					(pVampirePlayer->vComeToMeTini == TRUE &&
					fDistanceMeasurement(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,pVampirePlayer->vMassTini[0].vUnitParam.pDataUnits->pDataUnit,128*8) == FALSE) ||
					(pVampirePlayer->vComeToMeInfernal == TRUE &&
					fDistanceMeasurement(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,pVampirePlayer->vMassInfernal[0].vUnitParam.pDataUnits->pDataUnit,128*8) == FALSE) ||
					(pVampirePlayer->pPartner != NULL &&
					pVampirePlayer->pPartner->vComeToMeTini == TRUE &&
					pVampirePlayer->pPartner->vMassTini[0].vUnitParam.pDataUnits != NULL &&
					(unsigned int)pVampirePlayer->pPartner->vMassTini[0].vUnitParam.pDataUnits != 0xcdcdcdcd &&
					fDistanceMeasurement(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
										 pVampirePlayer->pPartner->vMassTini[0].vUnitParam.pDataUnits->pDataUnit,
										 128*8) == FALSE) ||
					(pVampirePlayer->pPartner != NULL &&
					pVampirePlayer->pPartner->vComeToMeInfernal == TRUE &&
					pVampirePlayer->pPartner->vMassInfernal[0].vUnitParam.pDataUnits != NULL &&
					(unsigned int)pVampirePlayer->pPartner->vMassInfernal[0].vUnitParam.pDataUnits != 0xcdcdcdcd &&
					fDistanceMeasurement(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
										 pVampirePlayer->pPartner->vMassInfernal[0].vUnitParam.pDataUnits->pDataUnit,
										 128*8) == FALSE))
					fActionGoToGlobal(pVampirePlayer,
									  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
									  pDataVampires->pPutGlobal,
									  128*16);
				if (pDataVampires->vAttack == FALSE)
				{
					goto m1;
				}
			}
		}
m3:;
	}
	/*else
	{
		if (pVampirePlayer->vSync == TRUE)
		{
			fActionGoToGlobal(pVampirePlayer,
							  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
						      pDataVampires->pPutGlobal,
						      0);
		}
	}*/
	return FALSE;
m1:
	return TRUE;
}

void fGoNextBase(VampirePlayer * pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
						if (fOrderToIdDataUnit(pVampirePlayer,
												pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
												ID_ORDER_MOVE,
												vManaWell) == TRUE)
						{
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit = 0;
							//pVampirePlayer->vVampire.vUnitParam.vRetreat = TRUE;
						}
						if (pVampirePlayer->pPartner != NULL)
						{
							if (fOrderToIdDataUnit(pVampirePlayer->pPartner,
													pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit,
													ID_ORDER_MOVE,
													vManaWell) == TRUE)
							{
								pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit = 0;
								//pVampirePlayer->pPartner->vVampire.vUnitParam.vRetreat = TRUE;
							}
						}
						pDataVampires->vFalgNextBase = TRUE;
						pDataVampires->vTimeNextBase = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
						pDataVampires->vTiniGo = FALSE;
						fEndAttack();
}

// Отступить назад на 3 клетки
bool fStepBack(VampirePlayer *pVampirePlayer, DataUnit *pDataUnit)
{
	if (pVampirePlayer == NULL || pDataUnit == NULL) return FALSE;
	pVampirePlayer->pDataUnit = fGetDataUnit(pDataUnit->TargetUnit);
	if (pVampirePlayer->pDataUnit == NULL) return FALSE;
						pVampirePlayer->vX_1 = pDataUnit->LastCoordinates.X;
						pVampirePlayer->vY_1 = pDataUnit->LastCoordinates.Y;
						pVampirePlayer->vX_2 = GetUnitX(pDataUnit->TargetUnit);
						pVampirePlayer->vY_2 = GetUnitY(pDataUnit->TargetUnit);
						pVampirePlayer->vDiffX = pVampirePlayer->vX_1 - pVampirePlayer->vX_2;
						pVampirePlayer->vDiffY = pVampirePlayer->vY_1 - pVampirePlayer->vY_2;
						if (pVampirePlayer->vDiffX < 0 &&
							abs(pVampirePlayer->vDiffY) < 120)
						{
							pVampirePlayer->vX_3 = pVampirePlayer->vX_2 - pVampirePlayer->vDiffX*3;
							pVampirePlayer->vY_3 = pVampirePlayer->vY_2 ;
							goto m15;
						}
						if (pVampirePlayer->vDiffY < 0 &&
							abs(pVampirePlayer->vDiffX) < 120)
						{
							pVampirePlayer->vX_3 = pVampirePlayer->vX_2;
							pVampirePlayer->vY_3 = pVampirePlayer->vY_2 + pVampirePlayer->vDiffY*3;
							goto m15;
						}
						if (pVampirePlayer->vDiffX > 0 &&
							abs(pVampirePlayer->vDiffY) < 120)
						{
							pVampirePlayer->vX_3 = pVampirePlayer->vX_2 + pVampirePlayer->vDiffX*3;
							pVampirePlayer->vY_3 = pVampirePlayer->vY_2;
							goto m15;
						}
						if (pVampirePlayer->vDiffY > 0 &&
							abs(pVampirePlayer->vDiffX) < 120)
						{
							pVampirePlayer->vX_3 = pVampirePlayer->vX_2;
							pVampirePlayer->vY_3 = pVampirePlayer->vY_2 - pVampirePlayer->vDiffY*3;
							goto m15;
						}
						return FALSE;
m15:
						if (GetUnitCurrentOrder(pDataUnit->WhichUnit) != ID_ORDER_MOVE)
						if (IssuePointOrderById(pDataUnit->WhichUnit,
							                    ID_ORDER_MOVE,
												pVampirePlayer->vX_3,
												pVampirePlayer->vY_3) == TRUE)
						{
							return TRUE;
						}
	return FALSE;
}

// Подвинуться около таргета
bool fMoveOver(VampirePlayer *pVampirePlayer, DataUnit *pDataUnit, DataUnit *pDataUnit2)
{
	if (pVampirePlayer == NULL || pDataUnit == NULL || pDataUnit2 == NULL) return FALSE;
	pVampirePlayer->pDataUnit = fGetDataUnit(pDataUnit->TargetUnit);
	if (pVampirePlayer->pDataUnit == NULL) return FALSE;
	pVampirePlayer->pDataUnit = fGetDataUnit(pDataUnit2->TargetUnit);
	if (pVampirePlayer->pDataUnit == NULL) return FALSE;
	if (pDataUnit->TargetUnit != pDataUnit2->TargetUnit) return FALSE;
						pVampirePlayer->vX_1 = pDataUnit->LastCoordinates.X;
						pVampirePlayer->vY_1 = pDataUnit->LastCoordinates.Y;
						pVampirePlayer->vX_2 = GetUnitX(pDataUnit->TargetUnit);
						pVampirePlayer->vY_2 = GetUnitY(pDataUnit->TargetUnit);
						pVampirePlayer->vDiffX = pVampirePlayer->vX_1 - pVampirePlayer->vX_2;
						pVampirePlayer->vDiffY = pVampirePlayer->vY_1 - pVampirePlayer->vY_2;
						if (pVampirePlayer->vDiffX < 0 &&
							abs(pVampirePlayer->vDiffY) < 18)
						{
							pVampirePlayer->vX_3 = pVampirePlayer->vX_2;
							if (pDataUnit2->LastCoordinates.Y < pDataUnit->LastCoordinates.Y)
							{
								pVampirePlayer->vY_3 = pVampirePlayer->vY_2 + 64;
							}
							else
							{
								pVampirePlayer->vY_3 = pVampirePlayer->vY_2 - 64;
							}
							goto m15;
						}
						if (pVampirePlayer->vDiffY < 0 &&
							abs(pVampirePlayer->vDiffX) < 18)
						{
							if (pDataUnit2->LastCoordinates.X < pDataUnit->LastCoordinates.X)
							{
								pVampirePlayer->vX_3 = pVampirePlayer->vX_2 + 64;
							}
							else
							{
								pVampirePlayer->vX_3 = pVampirePlayer->vX_2 - 64;
							}
							pVampirePlayer->vY_3 = pVampirePlayer->vY_2;
							goto m15;
						}
						if (pVampirePlayer->vDiffX > 0 &&
							abs(pVampirePlayer->vDiffY) < 18)
						{
							pVampirePlayer->vX_3 = pVampirePlayer->vX_2;
							if (pDataUnit2->LastCoordinates.Y < pDataUnit->LastCoordinates.Y)
							{
								pVampirePlayer->vY_3 = pVampirePlayer->vY_2 + 64;
							}
							else
							{
								pVampirePlayer->vY_3 = pVampirePlayer->vY_2 - 64;
							}
							goto m15;
						}
						if (pVampirePlayer->vDiffY > 0 &&
							abs(pVampirePlayer->vDiffX) < 18)
						{
							if (pDataUnit2->LastCoordinates.X < pDataUnit->LastCoordinates.X)
							{
								pVampirePlayer->vX_3 = pVampirePlayer->vX_2 + 64;
							}
							else
							{
								pVampirePlayer->vX_3 = pVampirePlayer->vX_2 - 64;
							}
							pVampirePlayer->vY_3 = pVampirePlayer->vY_2;
							goto m15;
						}
						return FALSE;
m15:
						if (GetUnitCurrentOrder(pDataUnit->WhichUnit) != ID_ORDER_MOVE)
						if (IssuePointOrderById(pDataUnit->WhichUnit,
							                    ID_ORDER_MOVE,
												pVampirePlayer->vX_3,
												pVampirePlayer->vY_3) == TRUE)
						{
							return TRUE;
						}
	return FALSE;
}

// Подойти на соотношение гипотинузы до таргета к одной клетки в направление таргета
bool fStepForward(VampirePlayer *pVampirePlayer, DataUnit *pDataUnit)
{
	if (pVampirePlayer == NULL || pDataUnit == NULL) return FALSE;
	pVampirePlayer->pDataUnit = fGetDataUnit(pDataUnit->TargetUnit);
	if (pVampirePlayer->pDataUnit == NULL) return FALSE;
	if (GetUnitCurrentOrder(pDataUnit->WhichUnit) == ID_ORDER_ATTACK )
	{
						pVampirePlayer->vX_1 = pDataUnit->LastCoordinates.X;
						pVampirePlayer->vY_1 = pDataUnit->LastCoordinates.Y;
						pVampirePlayer->vX_2 = GetUnitX(pDataUnit->TargetUnit);
						pVampirePlayer->vY_2 = GetUnitY(pDataUnit->TargetUnit);
						pVampirePlayer->vG = fG(pVampirePlayer->vX_1,pVampirePlayer->vY_1,pVampirePlayer->vX_2,pVampirePlayer->vY_2);
						pVampirePlayer->vDiffX = pVampirePlayer->vX_1 - pVampirePlayer->vX_2;
						pVampirePlayer->vDiffY = pVampirePlayer->vY_1 - pVampirePlayer->vY_2;
						pVampirePlayer->vX_3 = pVampirePlayer->vX_1 + ((-128)/pVampirePlayer->vG * pVampirePlayer->vDiffX);
						pVampirePlayer->vY_3 = pVampirePlayer->vY_1 + ((-128)/pVampirePlayer->vG * pVampirePlayer->vDiffY);
						if (IssuePointOrderById(pDataUnit->WhichUnit,
							                    ID_ORDER_MOVE,
												pVampirePlayer->vX_3,
												pVampirePlayer->vY_3) == TRUE)
						{
							return TRUE;
						}
	}
	return FALSE;
}

// Отойти на соотношение гипотинузы до таргета к одной клетки от таргета
bool fStepBack(VampirePlayer *pVampirePlayer, DataUnit *pDataUnit, real vR)
{
	if (pVampirePlayer == NULL || pDataUnit == NULL) return FALSE;
	pVampirePlayer->pDataUnit = fGetDataUnit(pDataUnit->TargetUnit);
	if (pVampirePlayer->pDataUnit == NULL) return FALSE;
	if (GetUnitCurrentOrder(pDataUnit->WhichUnit) != ID_ORDER_MOVE)
	{
						pVampirePlayer->vX_1 = pDataUnit->LastCoordinates.X;
						pVampirePlayer->vY_1 = pDataUnit->LastCoordinates.Y;
						pVampirePlayer->vX_2 = GetUnitX(pDataUnit->TargetUnit);
						pVampirePlayer->vY_2 = GetUnitY(pDataUnit->TargetUnit);
						pVampirePlayer->vG = fG(pVampirePlayer->vX_1,pVampirePlayer->vY_1,pVampirePlayer->vX_2,pVampirePlayer->vY_2);
						if (pVampirePlayer->vG > vR) return FALSE;
						pVampirePlayer->vDiffX = pVampirePlayer->vX_1 - pVampirePlayer->vX_2;
						pVampirePlayer->vDiffY = pVampirePlayer->vY_1 - pVampirePlayer->vY_2;
						pVampirePlayer->vX_3 = pVampirePlayer->vX_1 + (128/pVampirePlayer->vG * pVampirePlayer->vDiffX);
						pVampirePlayer->vY_3 = pVampirePlayer->vY_1 + (128/pVampirePlayer->vG * pVampirePlayer->vDiffY);
						if (IssuePointOrderById(pDataUnit->WhichUnit,
							                    ID_ORDER_MOVE,
												pVampirePlayer->vX_3,
												pVampirePlayer->vY_3) == TRUE)
						{
							return TRUE;
						}
	}
	return FALSE;
}

// Эту тактику интегрировать во вторую
bool fVampireTactics1(VampirePlayer *pVampirePlayer)
{
	/*if (pVampirePlayer == NULL) return FALSE;
	if (pVampirePlayer->vFarmBase != DO_NOT_FIND_BASE && pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE)
	{
		if (pVampirePlayer->vStealthON == FALSE || (pVampirePlayer->vStealthON == TRUE && pVampirePlayer->fStealthOff() == TRUE))
		{
			if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit != 0)
			{
				pVampirePlayer->vId = 0;
				if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit != NULL)
				{
					pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit);
				}
				if (fIsWall(pVampirePlayer->vId) == TRUE)
				{
					if (pVampirePlayer->pPartner != NULL &&
						pVampirePlayer->vFlagIPassedInvulnerability == FALSE &&
						pVampirePlayer->vInvulnerability == FALSE &&
						pVampirePlayer->vInvulnerability == pVampirePlayer->pPartner->vInvulnerability &&
						pVampirePlayer->vTransmitInvulnerability == FALSE &&
						pVampirePlayer->pPartner->vTransmitInvulnerability == FALSE &&
						pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_IMMORTALITY) == 0 &&
						pVampirePlayer->pPartner->vVampire.vInventory.fQItems(ID_ITEM_IMMORTALITY) >= 1)
					{
						pVampirePlayer->pPartner->vTransmitInvulnerability = TRUE;
						pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vPickupItem = FALSE;
						pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->vPickupItem = FALSE;
					}
					if (pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_BREEZE) > 0)
					{
					pVampirePlayer->hGroupFarm = CreateGroup();
					GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
										  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
										  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
										  128*3,Filter(&fFilterMainHuman));
					do
					{
						pVampirePlayer->u = FirstOfGroup(pVampirePlayer->hGroupFarm);
						if (pVampirePlayer->u != 0)
						{
							pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->u);
							if (fIsMainHuman(pVampirePlayer->vId) == TRUE)
							{
								pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = TRUE;
								if (UnitUseItemTarget(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
													  pVampirePlayer->vVampire.vInventory.fGetItem(ID_ITEM_BREEZE),
													  pVampirePlayer->u) == FALSE)
								{
									pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
									pVampirePlayer->vVampire.vInventory.fRefreshInventory();
									DestroyGroup(pVampirePlayer->hGroupFarm);
									goto m3;
								}
								pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
							}
						}
						GroupRemoveUnit(pVampirePlayer->hGroupFarm,pVampirePlayer->u);
					}
					while (pVampirePlayer->u != 0);
					DestroyGroup(pVampirePlayer->hGroupFarm);
					}
				}
				if (fIsWall(pVampirePlayer->vId) == TRUE && pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Atakuet == TRUE)
				{
					if ((pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeInvulnerability) >= 0 &&
						pVampirePlayer->vTransmitInvulnerability == FALSE &&
						GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
						(GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.6))
					{
						pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = TRUE;
						if (UnitUseItem(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
										pVampirePlayer->vVampire.vInventory.fGetItem(ID_ITEM_IMMORTALITY)) == TRUE)
						{
							pVampirePlayer->vFlagIPassedInvulnerability = FALSE;
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
							pVampirePlayer->vTransmitInvulnerability = TRUE;
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vPickupItem = FALSE;
							pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->vPickupItem = FALSE;
							//pVampirePlayer->vTimeAction = pVampirePlayer->vParamPlayer.vTimerGetElapsed + 0.5;
							pVampirePlayer->vTimeInvulnerability = pVampirePlayer->vParamPlayer.vTimerGetElapsed + 45;
							pVampirePlayer->vInvulnerability = TRUE;
							goto m1;
						}
						pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
					}
					if (pVampirePlayer->vVampire.vUnitParam.vRetreat == FALSE &&
						GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
						(GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.3))
					{
						if (fOrderToIdDataUnit(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,ID_ORDER_MOVE,vManaWell) == TRUE)
						{
							pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit = 0;
							pVampirePlayer->vVampire.vUnitParam.vRetreat = TRUE;
							goto m1;
						}
					}
				}
				if (fIsWall(pVampirePlayer->vId) == TRUE &&
					GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit) != ID_ORDER_ATTACK)
				{
					if (IssueTargetOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
											 ID_ORDER_ATTACK,
											 pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit) == TRUE)
					{
						pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vGoToGlobal = TRUE;
					}
					else
					{
						pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit = NULL;
					}
				}
			}
			if (pVampirePlayer->pPartner == NULL ||
				(pVampirePlayer->pPartner != NULL &&
				fComeToMe(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit,128*24) == FALSE))
			{
				fActionGoToGlobal(pVampirePlayer,
					              pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,pDataVampires->pPutGlobal,
								  128*16);
				if (pDataVampires->vAttack == FALSE)
				{
					goto m1;
				}
			}
		}
m3:;
	}
	return FALSE;
m1:*/
	return TRUE;
}

// Действия тини
void fActionsTini(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	if (pVampirePlayer->vFarmBase != DO_NOT_FIND_BASE && pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE)
	{
		pVampirePlayer->vFireInfernal = fGetDataUnit(pVampirePlayer->vFireInfernalUnit);
		if (pVampirePlayer->vFireInfernal == NULL)
		{
			pVampirePlayer->vFireInfernalUnit = NULL;
		}
		/*if (pVampirePlayer->pDataUnit != NULL)
		{
			for (pVampirePlayer->vvi = 0; pVampirePlayer->vvi < pVampirePlayer->MAX_INFERNAL; pVampirePlayer->vvi++)
			{
				if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits != NULL &&
					pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit != NULL &&
					fIsInfernal(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vId) == TRUE &&
					pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vFire == TRUE)
				{
					goto m5;
				}
			}
			pVampirePlayer->vFireInfernalUnit = NULL;
			pVampirePlayer->vFireInfernal = NULL;
m5:;
		}*/
		pVampirePlayer->vFlagTini = FALSE;
		for (pVampirePlayer->vvi = 0; pVampirePlayer->vvi < pVampirePlayer->MAX_TINI; pVampirePlayer->vvi++)
		{
			if (pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits == NULL ||
				(unsigned int)pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits == 0xcdcdcdcd) continue;
			fAddDataUnitInRange(pVampirePlayer,pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit);
			if (pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit != NULL &&
				pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vId != ID_UNIT_TINI)
			{
				pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits = NULL;
				continue;
			}
			if (pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit == NULL ||
				(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit != NULL &&
				pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vId != ID_UNIT_TINI)) continue;
			if (pVampirePlayer->vFlagTini == FALSE) pVampirePlayer->vFlagTini = TRUE;
			// Бежим к поднятому ветерком
			if (pDataVampires->vMainHumanBreeze != NULL)
			{
				if (pVampirePlayer->vvi >= 2)
				{
					if (IssuePointOrderById(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
											ID_ORDER_MOVE,
											pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X,
											pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y) == TRUE)
					{
						continue;
					}
				}
				pVampirePlayer->pDataUnit = fGetDataUnit(pDataVampires->vMainHumanBreeze->WhichUnit);
				if (pVampirePlayer->pDataUnit != NULL)
				{
					if (fBreezeToUnit(pVampirePlayer,
						              &pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam,
									  pDataVampires->vMainHumanBreeze,
									  pDataVampires->vTimerMainHumanBreeze,
									  pDataVampires->vFlagBreeze) == TRUE) 
									  continue;
				}
			}
			if (pDataVampires->vWall == TRUE)
			{
				if (pDataVampires->vTiniGo == FALSE &&
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->PermissionMove == TRUE)
				{
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->PermissionMove = FALSE;
				}
				if (pDataVampires->vTiniGo == TRUE &&
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->PermissionMove == FALSE)
				{
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->PermissionMove = TRUE;
				}
			}
			else
			{
				if (pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->PermissionMove == FALSE)
				{
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->PermissionMove = TRUE;
				}
			}
			// Обнуляем таргет
			pVampirePlayer->pDataUnit = fGetDataUnit(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit);
			if (pVampirePlayer->pDataUnit == NULL)
			{
				pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit = NULL;
			}
			// Если таргет не ноль
			if (pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit != 0)
			{
				// Детонируем тини
				if (GetUnitState(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
					(GetUnitState(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.1) &&
					IssuePointOrderById(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
										ID_ORDER_DETONATE,
										pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
										pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y) == TRUE)
				{
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits = NULL;
					//pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit = NULL;
					continue;
				}
				// Хилим тини
				if (pVampirePlayer->vHealMe == NULL &&
					GetUnitState(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
					(GetUnitState(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.4))
				{
					pVampirePlayer->vHealMe = pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit;
				}
				// Обнуляем путь после выздоровления
				if (pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.vRetreat == TRUE &&
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vGoToGlobal == TRUE &&
					pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE &&
					pDataVampires->vAttack == TRUE &&
					GetUnitState(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) >
					(GetUnitState(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.7))
				{
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vGoToGlobal = FALSE;
				}
				//pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit);
				if (pDataVampires->vWall == TRUE)
				{
					// Отступаем
					if (pDataVampires->vTiniGo == FALSE &&
						pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.vRetreat == FALSE &&
						((GetUnitState(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
						(GetUnitState(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.5))))
					{
						if (fOrderToIdDataUnit(pVampirePlayer,
											   pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,
											   ID_ORDER_MOVE,
											   vManaWell) == TRUE)
						{
							pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.vRetreat = TRUE;
							continue;
						}
					}
					// Атакуем Мейнов около вала
					if (pDataVampires->vTiniGo == TRUE)
					{
						pVampirePlayer->hGroupFarm = CreateGroup();
						GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
											  pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
											  pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
											  128*36,Filter(&fFilterMainHuman));
						pVampirePlayer->u = fGetNearestUnitEnemy(pVampirePlayer->hGroupFarm,pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,TRUE);
						DestroyGroup(pVampirePlayer->hGroupFarm);
						if (pVampirePlayer->u != 0 &&
							IssueTargetOrderById(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
												 ID_ORDER_ATTACK,
												 pVampirePlayer->u) == TRUE)
						{
							continue;
						}
					}
					pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit);
					if (fIsWall(pVampirePlayer->vId) == TRUE &&
						fStepBack(pVampirePlayer,pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit) == TRUE)
					{
						pVampirePlayer->vStepBack = TRUE;
						if (pVampirePlayer->pPartner != NULL)
							pVampirePlayer->pPartner->vStepBack = TRUE;
						continue;
					}	
					//pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit = 0;
					if (pVampirePlayer->vFireInfernalUnit != NULL)
					{
						if (pVampirePlayer->vMassTini[pVampirePlayer->vvi].vSmartFireInfernal == FALSE &&
							IssueTargetOrderById(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
												 ID_ORDER_SMART,
												 pVampirePlayer->vFireInfernalUnit) == TRUE)
						{
							pVampirePlayer->vMassTini[pVampirePlayer->vvi].vSmartFireInfernal = TRUE;
							continue;
						}
						if (pVampirePlayer->vMassTini[pVampirePlayer->vvi].vSmartFireInfernal == TRUE)
						{
							continue;
						}
					}
				}
				else
				{
					/*if (IssuePointOrderById(pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
											ID_ORDER_MOVE,
											pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X,
											pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y) == TRUE)
					{
						continue;
					}*/
				}
			}
			else
			{
				if (pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->PermissionMove == FALSE)
				{
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->PermissionMove = TRUE;
				}
			}
			if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X != 0 &&
				pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y != 0)
			{
				pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X = pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X;
				pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y = pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y;
			}
			if (fComeToMe(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
				          pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,
						  128*7) == FALSE)
			{
				fActionGoToGlobal(pVampirePlayer,
								  pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,
								  pDataVampires->pPutGlobal,
								  128*8);
			}
		}
		if (pVampirePlayer->vFlagTini == FALSE) pDataVampires->vTiniGo = FALSE;
	}
}

// Действия инфернала
void fActionsInfernal(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	if (pVampirePlayer->vFarmBase != DO_NOT_FIND_BASE && pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE)
	{
		pVampirePlayer->vFlagInfernal = FALSE;
		for (pVampirePlayer->vvi = 0; pVampirePlayer->vvi < pVampirePlayer->MAX_INFERNAL; pVampirePlayer->vvi++)
		{
			if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits == NULL ||
				(unsigned int)pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits == 0xcdcdcdcd) continue;
			fAddDataUnitInRange(pVampirePlayer,pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit);
			if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit != NULL &&
				fIsInfernal(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vId) == FALSE)
			{
				pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits = NULL;
				continue;
			}
			if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit == NULL ||
				(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit != NULL &&
				fIsInfernal(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vId) == FALSE)) continue;
			if (pVampirePlayer->vFlagInfernal == FALSE) pVampirePlayer->vFlagInfernal = TRUE;
			if (pDataVampires->vMainHumanBreeze != NULL)
			{
				if (IssuePointOrderById(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
										ID_ORDER_MOVE,
										pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X,
										pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y) == TRUE)
				{
					continue;
				}
				/*if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vSmartVampire == FALSE)
				{
					if (IssueTargetOrderById(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
											ID_ORDER_SMART,
											pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit) == TRUE)
					{
						pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vSmartVampire = TRUE;
					}
				}*/
			}
			pVampirePlayer->pDataUnit = fGetDataUnit(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit);
			if (pVampirePlayer->pDataUnit == NULL)
			{
				pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit = NULL;
			}
			// Напасть на вал, если вышло определённое время после атаки пушки
			if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit != 0 &&
				pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vTimeAttackTower != 0)
			{
				pVampirePlayer->vId = 0;
				if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit != NULL)
				{
					pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit);
				}
				if ((fIsFirstTower(pVampirePlayer->vId) == TRUE &&
					pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vTimeAttackTower >= 5) ||
					(fIsBigHPTower(pVampirePlayer->vId) == TRUE &&
					pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vTimeAttackTower >= 10))
				{
					//pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit = NULL;
					pVampirePlayer->hGroupFarm = CreateGroup();
					GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
										  pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
										  pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
										  128*8,Filter(&fFilterWall));
					pVampirePlayer->u = fGetNearestUnitEnemy(pVampirePlayer->hGroupFarm,pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,TRUE);
					DestroyGroup(pVampirePlayer->hGroupFarm);
					//pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit);
					if (pVampirePlayer->u != 0)
					{
						pVampirePlayer->vX_1 = pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X;
						pVampirePlayer->vY_1 = pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y;
						pVampirePlayer->vX_2 = GetUnitX(pVampirePlayer->u);
						pVampirePlayer->vY_2 = GetUnitY(pVampirePlayer->u);
						if(fG(pVampirePlayer->vX_1,
							  pVampirePlayer->vY_1,
							  pVampirePlayer->vX_2,
							  pVampirePlayer->vY_2) > 128 * 3 &&
							  fStepForward(pVampirePlayer,
							               pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit) == TRUE)
							  /*IssuePointOrderById(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
											      ID_ORDER_MOVE,
											      pVampirePlayer->vX_2,
												  pVampirePlayer->vY_2) == TRUE)*/
						{
							continue;
						}
						if (IssueTargetOrderById(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
												 ID_ORDER_ATTACK,
												 pVampirePlayer->u) == TRUE)
						{
							pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vTimeAttackTower = 0;
							pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit = pVampirePlayer->u;
							continue;
						}
					}
				}
			}
			if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit != 0)
			{
				if (pVampirePlayer->vHealMe == NULL &&
					GetUnitState(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
					(GetUnitState(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.4))
				{
					pVampirePlayer->vHealMe = pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit;
				}
				if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.vRetreat == TRUE &&
					pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vGoToGlobal == TRUE &&
					pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE &&
					pDataVampires->vAttack == TRUE &&
					GetUnitState(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) >
					(GetUnitState(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.6))
				{
					pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vGoToGlobal = FALSE;
				}
				//pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit);
				if (pDataVampires->vWall == TRUE)
				{
					pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit);
					if (fIsWall(pVampirePlayer->vId) == TRUE &&
						fStepBack(pVampirePlayer,pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,128*2) == TRUE)
					{
						continue;
					}
					// Отступаем
					if (pVampirePlayer->hGroupFarm,pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.vRetreat == FALSE &&
						GetUnitState(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
						(GetUnitState(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.5))
					{
						if (fOrderToIdDataUnit(pVampirePlayer,
											   pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,
											   ID_ORDER_MOVE,
											   vManaWell) == TRUE)
						{
							pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.vRetreat = TRUE;
							continue;
						}
					}
					// Атакуем пушки
					if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vFire == TRUE)
					{
						pVampirePlayer->hGroupFarm = CreateGroup();
						GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
											  pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
											  pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
											  128*16,Filter(&fFilterFirstTower));
						pVampirePlayer->u = fGetNearestUnitEnemy(pVampirePlayer->hGroupFarm,pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,TRUE);
						DestroyGroup(pVampirePlayer->hGroupFarm);
						pVampirePlayer->hGroupFarm = CreateGroup();
						GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
											  pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
											  pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
											  128*16,Filter(&fFilterFirstTower));
						pVampirePlayer->u2 = fGetNearestUnitEnemy(pVampirePlayer->hGroupFarm,pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,FALSE);
						DestroyGroup(pVampirePlayer->hGroupFarm);
						if (pVampirePlayer->u != 0 &&
							(pVampirePlayer->u2 == 0 ||
							pVampirePlayer->u2 != 0 &&
							pVampirePlayer->u == pVampirePlayer->u2) &&
							pVampirePlayer->u != pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vForerunnerUnit)
						{
							pVampirePlayer->vX_1 = pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X;
							pVampirePlayer->vY_1 = pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y;
							pVampirePlayer->vX_2 = GetUnitX(pVampirePlayer->u);
							pVampirePlayer->vY_2 = GetUnitY(pVampirePlayer->u);
							if(fG(pVampirePlayer->vX_1,
								  pVampirePlayer->vY_1,
								  pVampirePlayer->vX_2,
								  pVampirePlayer->vY_2) > 128 * 5 &&
								  fStepForward(pVampirePlayer,
											   pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit) == TRUE)
							{
								continue;
							}
							if (IssueTargetOrderById(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
												 ID_ORDER_ATTACK,
												 pVampirePlayer->u) == TRUE)
							{
								if (pVampirePlayer->vFarsight == TRUE) pVampirePlayer->vFarsight = FALSE;
								if (pVampirePlayer->pPartner != NULL &&
									pVampirePlayer->pPartner->vFarsight == TRUE) pVampirePlayer->pPartner->vFarsight = FALSE;
								pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vForerunnerUnit = pVampirePlayer->u;
								pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit = pVampirePlayer->u;
								pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vTimeAttackTower = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
								continue;
							}
						}
						if (pVampirePlayer->u != 0 &&
							pVampirePlayer->u2 != 0 &&
							pVampirePlayer->u != pVampirePlayer->u2)
						{
							if (pVampirePlayer->vFarsight == FALSE) pVampirePlayer->vFarsight = TRUE;
							if (pVampirePlayer->pPartner != NULL &&
								pVampirePlayer->pPartner->vFarsight == FALSE) pVampirePlayer->pPartner->vFarsight = TRUE;
							pDataVampires->fFreeFarsight();
							pDataVampires->fAddCoordinatesForFarsight(GetUnitX(pVampirePlayer->u2),GetUnitY(pVampirePlayer->u2));
						}
					}
					if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vFire == FALSE &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 10 &&
						fIsEnoughResourses(pVampirePlayer->vParamPlayer.vPlayer,&pVampirePlayer->vParamPlayer,N_RESEARCH_FIRE_INFERNAL,&pVampirePlayer->vIdResearch) == TRUE &&
						IssueImmediateOrderById(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,pVampirePlayer->vIdResearch) == TRUE)
					{
						pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits = NULL;
						//pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit = NULL;
						//pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vFire = FALSE;
						//pVampirePlayer->vFireInfernalUnit = pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit;
						//pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vFire = TRUE;
						continue;
					}
					if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.vRetreat == FALSE &&
						pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->Atakuet == FALSE)
					{
						if (IssueTargetOrderById(pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit,
												 ID_ORDER_ATTACK,
												 pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit) == TRUE)
						{
							pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vGoToGlobal = TRUE;
						}
						else
						{
							pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->TargetUnit = NULL;
						}
					}
				}
			}
			if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X != 0 &&
				pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y != 0)
			{
				pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X = pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X;
				pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y = pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y;
			}
			if (fComeToMe(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
				          pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,
						  128*16) == FALSE)
			{
				fActionGoToGlobal(pVampirePlayer,
								  pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit,
								  pDataVampires->pPutGlobal,
								  128*15);
			}
		}
		if (pVampirePlayer->vFlagInfernal == FALSE &&
			pDataVampires->vKillInfernals == TRUE)
		{
			pDataVampires->vKillInfernals = FALSE;
		}
	}
}

void fSkillVampire(sVampire *pVampire, integer vFlag)
{
	if (vFlag < 0 || vFlag > 5) return;
	if (pVampire == NULL) return;
	if (pVampire->vUnitParam.pDataUnits->pDataUnit == NULL) return;
	integer vIdSkill;
	vIdSkill = 0;
	if (vFlag >= 1 && vFlag <= 5)
	{
		switch (vFlag)
		{
		case 1:
			vIdSkill = ID_SKILL_HEALINGWAVE;
			pVampire->vHealingwave.lvl++;
			if (fGetCoolDown(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.CoolDown) == FALSE);
			if (fGetCoolDamage(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.Damage) == FALSE);
			if (fGetCoolDamage(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.vRadius) == FALSE);
			if (fGetManaSpell(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.vMana) == FALSE);
			break;
		case 2:
			vIdSkill = ID_SKILL_STEALS;
			pVampire->vStealth.lvl++;
			if (fGetCoolDown(pVampire->vStealth.vId,pVampire->vStealth.lvl,&pVampire->vStealth.CoolDown) == FALSE);
			break;
		case 3:
			vIdSkill = ID_SKILL_FARSIGHT;
			pVampire->vEnlightenment.lvl++;
			if (fGetCoolDown(pVampire->vEnlightenment.vId,pVampire->vEnlightenment.lvl,&pVampire->vEnlightenment.CoolDown) == FALSE);
			break;
		case 4:
			vIdSkill = ID_SKILL_CRIT;
			break;
		case 5:
			vIdSkill = ID_SKILL_CHAINLIGHTNING;
			pVampire->vLightning.lvl++;
			if (fGetCoolDamage(pVampire->vLightning.vId,pVampire->vLightning.lvl,&pVampire->vLightning.Damage) == FALSE);
			break;
		}
		SelectHeroSkill(pVampire->vUnitParam.pDataUnits->pDataUnit->WhichUnit,vIdSkill);
	}
	if (pVampire->vUnitParam.pDataUnits->pDataUnit->Lvl == FALSE) return;
	integer vSkillPoints = GetHeroSkillPoints(pVampire->vUnitParam.pDataUnits->pDataUnit->WhichUnit);
	integer vLevel = GetHeroLevel(pVampire->vUnitParam.pDataUnits->pDataUnit->WhichUnit);
	int vvi;
	if (vLevel == 3)
	{
		vIdSkill = ID_SKILL_HEALINGWAVE;
		SelectHeroSkill(pVampire->vUnitParam.pDataUnits->pDataUnit->WhichUnit,vIdSkill);
		pVampire->vHealingwave.lvl = 1;
		pVampire->vHealingwave.vId = ID_ORDER_HEALINGWAVE;
		pVampire->vHealingwave.vTimeCast = 0;
		pVampire->vHealingwave.Available = TRUE;
		if (fGetCoolDown(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.CoolDown) == FALSE);
		if (fGetCoolDamage(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.Damage) == FALSE);
		if (fGetCoolDamage(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.vRadius) == FALSE);
		if (fGetManaSpell(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.vMana) == FALSE);
		vIdSkill = ID_SKILL_STEALS;
		SelectHeroSkill(pVampire->vUnitParam.pDataUnits->pDataUnit->WhichUnit,vIdSkill);
		pVampire->vStealth.lvl = 1;
		pVampire->vStealth.vId = ID_ORDER_STEALS;
		pVampire->vStealth.vTimeCast = 0;
		pVampire->vStealth.Available = TRUE;
		if (fGetCoolDown(pVampire->vStealth.vId,pVampire->vStealth.lvl,&pVampire->vStealth.CoolDown) == FALSE);
		if (fGetManaSpell(pVampire->vStealth.vId,pVampire->vStealth.lvl,&pVampire->vStealth.vMana) == FALSE);
		vIdSkill = ID_SKILL_FARSIGHT;
		SelectHeroSkill(pVampire->vUnitParam.pDataUnits->pDataUnit->WhichUnit,vIdSkill);
		pVampire->vEnlightenment.lvl = 1;
		pVampire->vEnlightenment.vId = ID_ORDER_FARSIGHT;
		pVampire->vEnlightenment.vTimeCast = 0;
		pVampire->vEnlightenment.Available = TRUE;
		if (fGetCoolDown(pVampire->vEnlightenment.vId,pVampire->vEnlightenment.lvl,&pVampire->vEnlightenment.CoolDown) == FALSE);
		if (fGetManaSpell(pVampire->vEnlightenment.vId,pVampire->vEnlightenment.lvl,&pVampire->vEnlightenment.vMana) == FALSE);
		pVampire->vLightning.lvl = 0;
		pVampire->vLightning.vId = ID_ORDER_CHAINLIGHTNING;
		pVampire->vLightning.vTimeCast = 0;
		pVampire->vLightning.Available = TRUE;
		if (fGetCoolDown(pVampire->vLightning.vId,pVampire->vLightning.lvl,&pVampire->vLightning.CoolDown) == FALSE);
		if (fGetCoolDamage(pVampire->vLightning.vId,pVampire->vLightning.lvl,&pVampire->vLightning.vRadius) == FALSE);
		if (fGetManaSpell(pVampire->vLightning.vId,pVampire->vLightning.lvl,&pVampire->vLightning.vMana) == FALSE);
		pVampire->vUnitParam.pDataUnits->pDataUnit->Lvl = FALSE;
		return;
	}
	for (vvi = 0; vvi < vSkillPoints; vvi++)
	{
		switch(vLevel)
		{
		case 2:
		case 6:
		case 31:
		case 32:
		case 33:
		case 34:
		case 35:
		case 36:
			vIdSkill = ID_SKILL_HEALINGWAVE;
			pVampire->vHealingwave.lvl++;
			if (fGetCoolDown(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.CoolDown) == FALSE);
			if (fGetCoolDamage(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.Damage) == FALSE);
			if (fGetCoolDamage(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.vRadius) == FALSE);
			if (fGetManaSpell(pVampire->vHealingwave.vId,pVampire->vHealingwave.lvl,&pVampire->vHealingwave.vMana) == FALSE);
			break;
		case 3:
		case 8:
			vIdSkill = ID_SKILL_STEALS;
			pVampire->vStealth.lvl++;
			if (fGetCoolDown(pVampire->vStealth.vId,pVampire->vStealth.lvl,&pVampire->vStealth.CoolDown) == FALSE);
			break;
		case 4:
			vIdSkill = ID_SKILL_FARSIGHT;
			pVampire->vEnlightenment.lvl++;
			if (fGetCoolDown(pVampire->vEnlightenment.vId,pVampire->vEnlightenment.lvl,&pVampire->vEnlightenment.CoolDown) == FALSE);
			break;
		case 5:
		case 7:
		case 9:
		case 10:
		case 11:
		case 12:
		case 13:
		case 14:
			vIdSkill = ID_SKILL_CRIT;
			break;
		case 15:
		case 16:
		case 17:
		case 18:
		case 19:
		case 20:
		case 21:
		case 22:
		case 23:
		case 24:
		case 25:
		case 26:
		case 27:
		case 28:
		case 29:
		case 30:
			vIdSkill = ID_SKILL_CHAINLIGHTNING;
			pVampire->vLightning.lvl++;
			if (fGetCoolDamage(pVampire->vLightning.vId,pVampire->vLightning.lvl,&pVampire->vLightning.Damage) == FALSE);
			break;
		default:
			return;
		}
		SelectHeroSkill(pVampire->vUnitParam.pDataUnits->pDataUnit->WhichUnit,vIdSkill);
		pVampire->vUnitParam.pDataUnits->pDataUnit->Lvl = FALSE;
	}
}

unit fGetNearestUnitEnemyForVampire(HGROUP g, DataUnit *pDataUnit)
{
	if (pDataUnit == NULL) return NULL;
	if (g == NULL) return NULL;
	unit u;
	unit u2;
	unit u3;
	unit u4;
	unit u5;
	unit u6;
	unit u7;
	real vG1;
	real vG2;
	real vG3;
	real vG4;
	real vG5;
	real vG6;
	real vG7;
	integer vId;
	u2 = 0;
	u3 = 0;
	u4 = 0;
	u5 = 0;
	u6 = 0;
	u7 = 0;
	vG2 = 0;
	vG3 = 0;
	vG4 = 0;
	vG5 = 0;
	vG6 = 0;
	vG7 = 0;
	do
	{
		u=FirstOfGroup(g);
		if (u != 0)
		{
			if (IsUnitEnemy(u,pDataUnit->vPlayer) == TRUE &&
				IsUnitVisible(u,pDataUnit->vPlayer) == TRUE)
			{
				vId = GetUnitTypeId(u);
				
				vG1 = fG(pDataUnit->LastCoordinates.X,
						 pDataUnit->LastCoordinates.Y,
						 GetUnitX(u),
						 GetUnitY(u));
				if (fIsMainHuman(vId) == TRUE)
				{
					if (vG4 > vG1 || vG4 == 0)
					{
						u4 = u;
						vG4 = vG1;
					}
					goto m1;
				}
				if (fIsBuildFirst(vId) == TRUE)
				{
					if (vG3 > vG1 || vG3 == 0)
					{
						u3 = u;
						vG3 = vG1;
					}
				}
				if (fIsFirstTower(vId) == TRUE)
				{
					if (vG6 > vG1 || vG6 == 0)
					{
						u6 = u;
						vG6 = vG1;
					}
					//goto m1;
				}
				if (fIsWall(vId) == TRUE)
				{
					if (vG7 > vG1 || vG7 == 0)
					{
						u7 = u;
						vG7 = vG1;
					}
				}
				if (fIsHouse(vId) == TRUE)
				{
					if (vG5 > vG1 || vG5 == 0)
					{
						u5 = u;
						vG5 = vG1;
					}
				}
				else
				{
					if (vG2 > vG1 || vG2 == 0)
					{
						u2 = u;
						vG2 = vG1;
					}
				}
m1:;
			}
		}
		GroupRemoveUnit(g,u);
	}
	while (u != 0);
	if (u7 != 0 && vG7 <= 128)
	{
		return u7;
	}
	if (u6 != 0 && vG6 <= 128)
	{
		return u6;
	}
	if (u4 != 0 && vG4 <= 128*1)
	{
		return u4;
	}
	if (u3 != 0)
	{
		return u3;
	}
	if (u5 != 0 && vG5 <= 128)
	{
		return u5;
	}
	if (u6 != 0 && u7 == 0)
	{
		return u6;
	}
	if (u2 != 0)
	{
		return u2;
	}
	if (u4 != 0 && vG4 <= 128*6)
	{
		return u4;
	}
	if (u5 != 0)
	{
		return u5;
	}
	return 0;
}
/*				if (fIsFirstTower(pVampirePlayer->vId) == TRUE)
				{
					pVampirePlayer->vX_2 = GetUnitX(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit);
					pVampirePlayer->vY_2 = GetUnitY(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit);
					if (fG(pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
						   pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
						   pVampirePlayer->vX_2,
						   pVampirePlayer->vY_2) > 128*1)
					{
						pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->TargetUnit = NULL;
						goto m5;
					}
				}
				*/

unit fGetNearestUnitEnemy(HGROUP g, DataUnit *pDataUnit, bool vFlagVisible)
{
	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 (IsUnitEnemy(u,pDataUnit->vPlayer) == TRUE &&
				IsUnitVisible(u,pDataUnit->vPlayer) == vFlagVisible)
			{
				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;
}

unit fGetNearestUnit(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;
}

unit fGetNearestUnitEnemyForInfernal(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 (IsUnitEnemy(u,pDataUnit->vPlayer) == TRUE &&
				IsUnitVisible(u,pDataUnit->vPlayer) == TRUE)
			{
				vId = GetUnitTypeId(u);
				
				vG1 = fG(pDataUnit->LastCoordinates.X,
						 pDataUnit->LastCoordinates.Y,
						 GetUnitX(u),
						 GetUnitY(u));
				if (fIsMainHuman(vId) == TRUE)
				{
					goto m2;
				}
				else
				{
					if (vG2 > vG1 || vG2 == 0)
					{
						u2 = u;
						vG2 = vG1;
					}
				}
			}
		}
m2:
		GroupRemoveUnit(g,u);
	}
	while (u != 0);
	if (u2 != 0)
	{
		return u2;
	}
	return 0;
}

/*unit fGetNearestUnitEnemyForInfernalFire(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 (IsUnitEnemy(u,pDataUnit->vPlayer) == TRUE &&
				IsUnitVisible(u,pDataUnit->vPlayer) == TRUE)
			{
				vId = GetUnitTypeId(u);
				
				vG1 = fG(pDataUnit->LastCoordinates.X,
						 pDataUnit->LastCoordinates.Y,
						 GetUnitX(u),
						 GetUnitY(u));
				if (fIsMainHuman(vId) == TRUE)
				{
					goto m2;
				}
				else
				{
					if (vG2 > vG1 || vG2 == 0)
					{
						u2 = u;
						vG2 = vG1;
					}
				}
			}
		}
m2:
		GroupRemoveUnit(g,u);
	}
	while (u != 0);
	if (u2 != 0 && vG2 <= 128*4)
	{
		return u2;
	}
	return 0;
}*/

bool fVampireGetGoldCoin(VampirePlayer * pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
	if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit == NULL) return FALSE;
	pVampirePlayer->vItem = 0;
	if (IsItemVisible(pVampirePlayer->vGoldCoin) == FALSE)
	{
		SaveInteger(vHT,pVampirePlayer->vParamPlayer.vTimerPlayer,CONST_FLAG_FOR_GOLD_COIN,1);
		SavePlayerHandle(vHT,pVampirePlayer->vParamPlayer.vTimerPlayer,CONST_PLAYER_FOR_GOLD_COIN,pVampirePlayer->vParamPlayer.vPlayer);
		SaveInteger(vHT,pVampirePlayer->vParamPlayer.vTimerPlayer,CONST_ID_UNIT_FOR_GOLD_COIN,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vId);
		SaveReal(vHT,pVampirePlayer->vParamPlayer.vTimerPlayer,CONST_HUNIT_VAMPIRE_X,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X);
		SaveReal(vHT,pVampirePlayer->vParamPlayer.vTimerPlayer,CONST_HUNIT_VAMPIRE_Y,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y);
		SaveItemHandle(vHT,pVampirePlayer->vParamPlayer.vTimerPlayer,CONST_GOLD_COIN,0);
		EnumItemsInRect(vWorldRect, NULL, &fActionItemsGold);
		pVampirePlayer->vItem = LoadItemHandle(vHT,pVampirePlayer->vParamPlayer.vTimerPlayer,CONST_GOLD_COIN);
	}
	else
	{
		if (pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeItemGold < 2)
		{
			return FALSE;
		}
		pVampirePlayer->vItem = pVampirePlayer->vGoldCoin;
	}	
	
	if (pVampirePlayer->vItem != 0)
	{
		pVampirePlayer->vX_1 = GetUnitX(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit);
		pVampirePlayer->vY_1 = GetUnitY(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit);
		pVampirePlayer->vX_2 = GetItemX(pVampirePlayer->vItem);
		pVampirePlayer->vY_2 = GetItemY(pVampirePlayer->vItem);
		pVampirePlayer->vG = fG(pVampirePlayer->vX_1,pVampirePlayer->vY_1,pVampirePlayer->vX_2,pVampirePlayer->vY_2);// = sqrtf(powf(abs(vX_1 - vX_2),2)+powf(abs(vY_1 - vY_2),2));
		if (pVampirePlayer->vG > 128)
		{
			if (IssuePointOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
				ID_ORDER_MOVE,
				pVampirePlayer->vX_2,pVampirePlayer->vY_2) == TRUE)
			{
				return FALSE;
			}
		}
		else
		{
			//IssueImmediateOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,0);
			if (IssueTargetOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
				ID_ORDER_SMART,
				pVampirePlayer->vItem) == TRUE)
			{
				pVampirePlayer->vTimeItemGold = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
				return TRUE;
			}
		}
	}
	return FALSE;
}

void fInitTroopsVampire(VampirePlayer * pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	pVampirePlayer->vQNewUnit = pVampirePlayer->vActionStackForUnits.vQNewUnit;
	for (pVampirePlayer->vvi = 0; pVampirePlayer->vvi < pVampirePlayer->vQNewUnit; pVampirePlayer->vvi++)
	{
		pVampirePlayer->pDataUnit = pVampirePlayer->vActionStackForUnits.fFindNewUnit();
		if (pVampirePlayer->pDataUnit != NULL)
		switch (pVampirePlayer->pDataUnit->vId)
		{
		case ID_UNIT_TINI:
			for (pVampirePlayer->vvi = 0; pVampirePlayer->vvi < pVampirePlayer->MAX_TINI; pVampirePlayer->vvi++)
			{
				if (pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits == NULL ||
					(unsigned int)pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits == 0xcdcdcdcd)
				{
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.pDataUnits = &vDataUnits[pVampirePlayer->pDataUnit->vIdDataUnit];
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vSmartFireInfernal = FALSE;
					pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.vRetreat = FALSE;
					//pVampirePlayer->vMassTini[pVampirePlayer->vvi].vUnitParam.vHoldPosition = FALSE;
					break;
				}
			}
			break;
		case ID_UNIT_INFERNAL:
		case ID_UNIT_FIRE_INFERNAL:
		case ID_UNIT_ACIDIC_INFERNAL:
		case ID_UNIT_FROST_INFERNAL:
			for (pVampirePlayer->vvi = 0; pVampirePlayer->vvi < pVampirePlayer->MAX_INFERNAL; pVampirePlayer->vvi++)
			{
				if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits == NULL ||
					(unsigned int)pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits == 0xcdcdcdcd)
				{
					pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits = &vDataUnits[pVampirePlayer->pDataUnit->vIdDataUnit];
					if (pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->vId == ID_UNIT_FIRE_INFERNAL)
					{
						pVampirePlayer->vFireInfernalUnit = pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit->WhichUnit;
						pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vFire = TRUE;
						pVampirePlayer->vFireInfernal = pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.pDataUnits->pDataUnit;
					}
					else
					{
						pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vFire = FALSE;
					}
					pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vTimeAttackTower = 0;
					pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.vRetreat = FALSE;
					pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vSmartVampire = FALSE;
					//pVampirePlayer->vMassInfernal[pVampirePlayer->vvi].vUnitParam.vHoldPosition = FALSE;
					break;
				}
			}
			break;
		case ID_UNIT_VAMPIRIC_RC:
			pVampirePlayer->vRC = pVampirePlayer->pDataUnit;
			break;
		default:
			break;
		}
	}
}

void fActionGoToGlobal(VampirePlayer *pVampirePlayer, DataUnit *pDataUnit, DataGoTo *pDataGoTo, real vR)
{
	if (pDataUnit == NULL || pDataGoTo == NULL) return;
	if (pDataUnit->PermissionMove == FALSE &&
		pVampirePlayer->vTimePermissionMove == 0)
	{
		pVampirePlayer->vTimePermissionMove = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
	}
	if (pDataUnit->PermissionMove == FALSE &&
		pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimePermissionMove > 10)
	{
		pDataUnit->PermissionMove = TRUE;
		pVampirePlayer->vTimePermissionMove = 0;
	}
	if (pDataUnit->PermissionMove == FALSE)
	{
		pVampirePlayer->pDataUnit = fGetDataUnit(pDataUnit->WhichUnit);
		if (pVampirePlayer->pDataUnit == NULL) return;
		IssueImmediateOrderById(pDataUnit->WhichUnit,ID_ORDER_STOP);
		if (IssuePointOrderById(pDataUnit->WhichUnit,ID_ORDER_MOVE,pDataUnit->LastCoordinates.X,pDataUnit->LastCoordinates.Y) == TRUE)
		{
			return;
		}
	}
	if (pDataUnit->vGoToGlobal == TRUE)
	{
		pVampirePlayer->pDataUnit = fGetDataUnit(pDataUnit->TargetUnit);
		if (pVampirePlayer->pDataUnit != NULL &&
			pVampirePlayer->pDataUnit->LastCoordinatesForEnemy.X != 0 &&
			pVampirePlayer->pDataUnit->LastCoordinatesForEnemy.Y != 0 &&
			fIsWall(pVampirePlayer->pDataUnit->vId) == FALSE &&
			IsUnitVisible(pDataUnit->TargetUnit,pDataUnit->vPlayer) == TRUE &&
			fFindBaseByDataUnit(pVampirePlayer->pDataUnit) != fFindBaseByDataUnitNoEnemy(pDataUnit))
		{
			pVampirePlayer->pDataUnit = NULL;
		}
		pVampirePlayer->vG = 0;
		if (pVampirePlayer->pDataUnit != NULL)
		{
			pVampirePlayer->vX_1 = pDataUnit->LastCoordinates.X;
			pVampirePlayer->vY_1 = pDataUnit->LastCoordinates.Y;
			pVampirePlayer->vX_2 = pVampirePlayer->pDataUnit->LastCoordinates.X;
			pVampirePlayer->vY_2 = pVampirePlayer->pDataUnit->LastCoordinates.Y;
			pVampirePlayer->vG = fG(pVampirePlayer->vX_1,pVampirePlayer->vY_1,pVampirePlayer->vX_2,pVampirePlayer->vY_2);
		}
		if (pVampirePlayer->pDataUnit == NULL ||
			(pVampirePlayer->pDataUnit != NULL &&
			((pVampirePlayer->vG > 128*16) ||
			IsUnitVisible(pDataUnit->TargetUnit,pDataUnit->vPlayer) == FALSE)))
		{
			pDataUnit->vGoToGlobal = FALSE;
		}
		if (pVampirePlayer->vTimeAttack != 0 &&
			(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeAttack > 10))
		{
			pDataUnit->vGoToGlobal = FALSE;
		}
	}
	if (pDataUnit->vGoToGlobal == FALSE)
	{
		pVampirePlayer->pDataUnit = fGetDataUnit(pDataUnit->WhichUnit);
		if (pVampirePlayer->pDataUnit == NULL) return;
		fAddDataUnitInRange(pVampirePlayer,pDataUnit);
		pVampirePlayer->pDataUnit2 = NULL;
		if (pVampirePlayer->vParamPlayer.vTimerGetElapsed - pDataVampires->vTimeNextBase >= 10)
		{
			pVampirePlayer->hGroupFarm = CreateGroup();
			pVampirePlayer->u = NULL;
			GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,pDataUnit->LastCoordinates.X,pDataUnit->LastCoordinates.Y,vR,NULL);
			if (fIsVampire(pDataUnit->vId) == TRUE || pDataUnit->vId == ID_UNIT_TINI)
			{
				pVampirePlayer->u = fGetNearestUnitEnemyForVampire(pVampirePlayer->hGroupFarm,pDataUnit);
			}
			else if (fIsInfernal(pDataUnit->vId) == TRUE)
			{
				pVampirePlayer->u = fGetNearestUnitEnemyForInfernal(pVampirePlayer->hGroupFarm,pDataUnit);
			}
			DestroyGroup(pVampirePlayer->hGroupFarm);
			if (pVampirePlayer->u != 0)
			{
				pVampirePlayer->pDataUnit2 = fGetDataUnit(pVampirePlayer->u);
				if (pVampirePlayer->pDataUnit2 != NULL &&
					pVampirePlayer->pDataUnit2->LastCoordinatesForEnemy.X != 0 &&
					pVampirePlayer->pDataUnit2->LastCoordinatesForEnemy.Y != 0 &&
					fIsWall(pVampirePlayer->pDataUnit2->vId) == FALSE &&
					GetTerrainCliffLevel(pVampirePlayer->pDataUnit->CoordinatesForGoToGlobal.X,pVampirePlayer->pDataUnit->CoordinatesForGoToGlobal.Y) <
					GetTerrainCliffLevel(pVampirePlayer->pDataUnit2->LastCoordinatesForEnemy.X,pVampirePlayer->pDataUnit2->LastCoordinatesForEnemy.Y))//fFindBaseByDataUnit(pVampirePlayer->pDataUnit2) != fFindBaseByDataUnitNoEnemy(pDataUnit))
				{
					pVampirePlayer->pDataUnit2 = NULL;
					goto m17;
				}
			}
		}
		if (pVampirePlayer->pDataUnit2 != 0)
		{
			pVampirePlayer->vG = fG(pVampirePlayer->pDataUnit2->LastCoordinates.X,
									pVampirePlayer->pDataUnit2->LastCoordinates.Y,
									pDataUnit->LastCoordinates.X,
									pDataUnit->LastCoordinates.Y);
		}
		if (pVampirePlayer->pDataUnit3 &&
			pVampirePlayer->vG > 200 &&
			pVampirePlayer->vG < 600)
		{
			goto m14;
		}
		if (pVampirePlayer->pDataUnit2 != 0 &&
			pVampirePlayer->vG <= vR)
		{
			pVampirePlayer->pDataUnit3 = NULL;
			//pVampirePlayer->pDataUnit3 = pVampirePlayer->pDataUnit2;
			//pVampirePlayer->vTimeTestGoTo = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
			if (pDataUnit->vGoTo == TRUE &&
				pVampirePlayer->vG > 200 &&
				fIsWall(pVampirePlayer->pDataUnit2->vId) == FALSE)
			{
				if (pVampirePlayer->vTimeTestGoTo == 0)
				{
					goto m16;
				}
				if ((pVampirePlayer->vParamPlayer.vTimerGetElapsed > pVampirePlayer->vTimeTestGoTo) &&
					pVampirePlayer->vTimeTestGoTo != 0)
				{
					if(fCheckGoTo(pDataUnit->vIdDataUnit) != 1)
					{
						if (pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeTestGoTo > 1)
						{
							pVampirePlayer->pDataUnit3 = pVampirePlayer->pDataUnit2;
							pVampirePlayer->vTimeTestGoTo = 0;
							goto m14;//Говорю иди дальше по глобал пути
						}
						else
						{
							return;
						}
					}
					else
					{
						pVampirePlayer->vTimeTestGoTo = 0;
						goto m15;//Говорю атакуй цель
					}
				}
m16:
				if (fUnitGoToInt(pDataUnit->vIdDataUnit,
								 fConvertXYToI(fConverterX(GetUnitX(pVampirePlayer->pDataUnit2->WhichUnit)),fConverterY(GetUnitY(pVampirePlayer->pDataUnit2->WhichUnit))),
								 ACTION_GO,
								 LIMIT_GOTO_R) == 1)
					pVampirePlayer->vTimeTestGoTo = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
				return;
			}
m15:
			pDataUnit->TargetUnit = pVampirePlayer->u;
			if (IssueTargetOrderById(pDataUnit->WhichUnit,ID_ORDER_ATTACK,pDataUnit->TargetUnit) == TRUE)
			{
				pVampirePlayer->vTimeAttack = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
				pDataUnit->vGoToGlobal = TRUE;
			}
			else
			{
				pDataUnit->TargetUnit = NULL;
			}
		}
		else
		{
m14:
			pVampirePlayer->vIdOrder = GetUnitCurrentOrder(pDataUnit->WhichUnit);
			if (pVampirePlayer->vIdOrder != ID_ORDER_MOVE)
			{
m17:
			if (pDataUnit->CoordinatesForGoToGlobal.X != 0 && pDataUnit->CoordinatesForGoToGlobal.Y != 0)
			{
				pVampirePlayer->vG = fG(pDataUnit->CoordinatesForGoToGlobal.X,
										pDataUnit->CoordinatesForGoToGlobal.Y,
										pDataUnit->LastCoordinates.X,
										pDataUnit->LastCoordinates.Y);
				if (pVampirePlayer->vFlagPullYourselfUp == TRUE &&
					pVampirePlayer->vG < 128 * 16)
				{
					pVampirePlayer->vFlagPullYourselfUp = FALSE;
					//pVampirePlayer->vComeToMe = TRUE;
				}
				pDataGoTo->vR = (unsigned int)(pVampirePlayer->vG/(float)DOOD_MAP_SUBDIV/4);
				if (pDataGoTo->vR == 0)
				{
					pDataGoTo->vR = 16;
				}
				pDataGoTo->vRect4.vX1 = fConverterX(pDataUnit->CoordinatesForGoToGlobal.X-pDataGoTo->vRadius_Unit+(float)DOOD_MAP_SUBDIV/4);
				pDataGoTo->vRect4.vY1 = fConverterY(pDataUnit->CoordinatesForGoToGlobal.Y+pDataGoTo->vRadius_Unit-(float)DOOD_MAP_SUBDIV/4);
				pDataGoTo->vRect4.vX2 = pDataGoTo->vRect4.vX1 + pDataGoTo->vDiff - 1;
				pDataGoTo->vRect4.vY2 = pDataGoTo->vRect4.vY1 + pDataGoTo->vDiff - 1;
			}
			else
			{
				pDataGoTo->vRect4.vX1 = fConverterX(pDataGoTo->vX_Unit-pDataGoTo->vRadius_Unit+(float)DOOD_MAP_SUBDIV/4);
				pDataGoTo->vRect4.vY1 = fConverterY(pDataGoTo->vY_Unit+pDataGoTo->vRadius_Unit-(float)DOOD_MAP_SUBDIV/4);
				pDataGoTo->vRect4.vX2 = pDataGoTo->vRect4.vX1 + pDataGoTo->vDiff - 1;
				pDataGoTo->vRect4.vY2 = pDataGoTo->vRect4.vY1 + pDataGoTo->vDiff - 1;
				pDataGoTo->vR = 16;
			}
			pDataGoTo->vCurrentIntFill = fGetCurrentIntFill(pDataGoTo->pFillMap,&pDataGoTo->vRect4);
			if (pDataVampires->vAttack == TRUE && pDataGoTo->vCurrentIntFill == 0)
			{
				pDataUnit->CoordinatesForGoToGlobal.X = 0;
				pDataUnit->CoordinatesForGoToGlobal.Y = 0;
				if (pVampirePlayer->pPartner != NULL)
				{
					pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X = 0;
					pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y = 0;
				}
			}
			/*if (pDataGoTo->vCurrentIntFill == 0)
			{
				pDataGoTo->vCurrentIntFill = pDataGoTo->vCurrentIntFill;
				//pDataGoTo->vCurrentIntFill = JASS_M1;
			}*/
			if (pDataVampires->vAttack == TRUE &&
				pDataGoTo->vCurrentIntFill <= JASS_M1 &&
				pDataGoTo->vCurrentIntFill > 0)
			{
				fEndAttack();
				pVampirePlayer->vVampire.vUnitParam.vAttack = FALSE;
				if (pVampirePlayer->pPartner != NULL)
				{
					pVampirePlayer->pPartner->vVampire.vUnitParam.vAttack = FALSE;
				}
			}
			/*if (pDataGoTo->vCurrentIntFill <= JASS_M1 + 5 &&
				pDataGoTo->vCurrentIntFill > 0 &&
				(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeMove > 5))
			{
				//fEndAttack();
				pVampirePlayer->vVampire.vUnitParam.vAttack = FALSE;
				if (pVampirePlayer->pPartner != NULL)
				{
					pVampirePlayer->pPartner->vVampire.vUnitParam.vAttack = FALSE;
				}
				pDataUnit->CoordinatesForGoToGlobal.X = 0;
				pDataUnit->CoordinatesForGoToGlobal.Y = 0;
				if (pVampirePlayer->pPartner != NULL)
				{
					pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X = 0;
					pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y = 0;
				}
			}*/
			if (pDataGoTo->vCurrentIntFill > 0)
			{
				if (pDataGoTo->vR != 0 && pDataGoTo->vCurrentIntFill - JASS_M1 < pDataGoTo->vR)
				{
					pDataGoTo->vR = pDataGoTo->vCurrentIntFill - JASS_M1;
				}
				while(pDataGoTo->vR>0)
				{
					pDataGoTo->vNextIntFill = pDataGoTo->vCurrentIntFill - pDataGoTo->vR;	
					if (fGetINext(pDataGoTo->pFillMap,&pDataGoTo->vRect4,&pDataGoTo->vRect5,pDataGoTo->vNextIntFill,pDataGoTo->vR,pDataGoTo->vDiff) == TRUE)
					{
						pDataGoTo->vForerunnerClifLevel = GetTerrainCliffLevel(pDataUnit->CoordinatesForGoToGlobal.X,pDataUnit->CoordinatesForGoToGlobal.Y);
						//GetTerrainCliffLevel
						fIssuePointOrderToRect(pDataUnit->WhichUnit,pDataGoTo->vActionStr,&pDataGoTo->vRect5,pDataGoTo->vRadius_Unit);
						fCenterToRect(&pDataUnit->CoordinatesForGoToGlobal,&pDataGoTo->vRect5);
						pDataGoTo->vSubsequentClifLevel = GetTerrainCliffLevel(pDataUnit->CoordinatesForGoToGlobal.X,pDataUnit->CoordinatesForGoToGlobal.Y);
						if (pDataGoTo->vForerunnerClifLevel < pDataGoTo->vSubsequentClifLevel)
						{
							pDataUnit->vRaisingClifLevel = TRUE;
							pDataUnit->vTimerRaisingClifLevel = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
						}
						pVampirePlayer->vTimeMove = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
						break;
					}
					pDataGoTo->vR--;
				}
			}
			else
			{
				pDataUnit->CoordinatesForGoToGlobal.X = 0;
				pDataUnit->CoordinatesForGoToGlobal.Y = 0;
			}
			}
		}
	}
}

bool fDistanceMeasurement(DataUnit *pDataUnit1, DataUnit *pDataUnit2, real vR)
{
	if (pDataUnit1 == NULL || pDataUnit2 == NULL) return FALSE;
	real vG;
	fRephreshLastCoordinates(pDataUnit1);
	fRephreshLastCoordinates(pDataUnit2);
	vG = fG(pDataUnit1->LastCoordinates.X,pDataUnit1->LastCoordinates.Y,pDataUnit2->LastCoordinates.X,pDataUnit2->LastCoordinates.Y);
	if (vG > vR)
	{
		return TRUE;
	}
	return FALSE;
}

bool fComeToMe(DataUnit *pDataUnit1, DataUnit *pDataUnit2, real vR)
{
	if (pDataUnit1 == NULL || pDataUnit2 == NULL) return FALSE;
	if (fDistanceMeasurement(pDataUnit1,pDataUnit2,vR) == TRUE)
	{
		if (//GetUnitCurrentOrder(pDataUnit2->WhichUnit) != ID_ORDER_MOVE &&
			IssuePointOrderById(pDataUnit2->WhichUnit,
								ID_ORDER_MOVE,
								pDataUnit1->LastCoordinates.X,
								pDataUnit1->LastCoordinates.Y) == TRUE)
		{
			return TRUE;
		}
	}
	return FALSE;
}

integer fFilterWall()
{
	HUNIT u = GetFilterUnit();
	if (u == NULL) return FALSE;
	integer vId;
	vId = GetUnitTypeId(u);
	if (fIsWall(vId) == TRUE)
	{
		return TRUE;
	}
	return FALSE;
}

integer fFilterMainHuman()
{
	HUNIT u = GetFilterUnit();
	if (u == NULL) return FALSE;
	integer vId;
	vId = GetUnitTypeId(u);
	if (fIsMainHuman(vId) == TRUE)
	{
		return TRUE;
	}
	return FALSE;
}

integer fFilterInfernal()
{
	HUNIT u = GetFilterUnit();
	if (u == NULL) return FALSE;
	integer vId;
	vId = GetUnitTypeId(u);
	if (fIsInfernal(vId) == TRUE)
	{
		return TRUE;
	}
	return FALSE;
}

integer fFilterFirstTower()
{
	HUNIT u = GetFilterUnit();
	if (u == NULL) return FALSE;
	integer vId;
	vId = GetUnitTypeId(u);
	if (fIsFirstTower(vId) == TRUE)
	{
		return TRUE;
	}
	return FALSE;
}

// Возвращаемся после отступления
void fWeReturnAfterTheRetreat(VampirePlayer * pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	if (pVampirePlayer->vVampire.vUnitParam.vRetreat == TRUE &&
		pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE &&
		pDataVampires->vAttack == TRUE &&
		GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) >
		(GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.6))
	{
		pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vGoToGlobal = FALSE;
		pVampirePlayer->vVampire.vUnitParam.vRetreat = FALSE;
	}
}

// Обнуляем разрешение
void fResetTheResolution(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	if ((pVampirePlayer->vVampire.vEnlightenment.Available == FALSE &&
		(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vVampire.vEnlightenment.vTimeCast) >= 0.2) ||
		(pVampirePlayer->vVampire.vHealingwave.Available == FALSE &&
		(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vVampire.vHealingwave.vTimeCast) >= 0.2) ||
		(pVampirePlayer->vVampire.vStealth.Available == FALSE &&
		(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vVampire.vStealth.vTimeCast) >= 0.2) ||
		(pVampirePlayer->vVampire.vLightning.Available == FALSE &&
		(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vVampire.vLightning.vTimeCast) >= 0.2))
	{
		pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
	}
	// Таймер бессмертия
	if (pVampirePlayer->vInvulnerability == TRUE &&
		(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeInvulnerability >= 10))
	{
		pVampirePlayer->vInvulnerability = FALSE;
	}
}

// Стелс
bool fStealth(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
	if (pVampirePlayer->vStealth == TRUE)
	{
		if (pVampirePlayer->vVampire.vStealth.Available == FALSE &&
			pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vVampire.vStealth.vTimeCast >= pVampirePlayer->vVampire.vStealth.CoolDown)
		{
			pVampirePlayer->vVampire.vStealth.Available = TRUE;
		}
		if (pVampirePlayer->vVampire.vStealth.Available == TRUE && pVampirePlayer->fStealth() == TRUE)
		{
			pVampirePlayer->vVampire.vStealth.vTimeCast = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
			pVampirePlayer->vVampire.vStealth.Available = FALSE;
			return TRUE;
		}
	}
	return FALSE;
}

// Лечение
bool fTreatment(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
	if (pVampirePlayer->vHealingwave == TRUE)
	{
		if (pVampirePlayer->vVampire.vHealingwave.Available == FALSE &&
			pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vVampire.vHealingwave.vTimeCast >= pVampirePlayer->vVampire.vHealingwave.CoolDown)
		{
			pVampirePlayer->vVampire.vHealingwave.Available = TRUE;
		}
		if (pVampirePlayer->vVampire.vHealingwave.Available == TRUE)
		{
			pVampirePlayer->vFlagHealingwave = FALSE;
			if (pVampirePlayer->vFlagHealingwave == FALSE &&
				pVampirePlayer->fHealingwaveOnYourself() == TRUE)
			{
				pVampirePlayer->vFlagHealingwave = TRUE;
			}
			if (pVampirePlayer->pPartner != NULL &&
				pVampirePlayer->vFlagHealingwave == FALSE &&
				pVampirePlayer->fHealingwave(pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit) == TRUE)
			{
				pVampirePlayer->vFlagHealingwave = TRUE;
			}
			if (pVampirePlayer->vFlagHealingwave == FALSE &&
				pVampirePlayer->vHealMe != NULL &&
				pVampirePlayer->fHealingwave(pVampirePlayer->vHealMe) == TRUE)
			{
				pVampirePlayer->vHealMe = NULL;
				pVampirePlayer->vFlagHealingwave = TRUE;
			}
			if (pVampirePlayer->pPartner != NULL &&
				pVampirePlayer->vFlagHealingwave == FALSE &&
				pVampirePlayer->pPartner->vHealMe != NULL &&
				pVampirePlayer->fHealingwave(pVampirePlayer->pPartner->vHealMe) == TRUE)
			{
				pVampirePlayer->pPartner->vHealMe = NULL;
				pVampirePlayer->vFlagHealingwave = TRUE;
			}
			if (pVampirePlayer->vFlagHealingwave == TRUE)
			{
				pVampirePlayer->vVampire.vHealingwave.vTimeCast = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
				pVampirePlayer->vVampire.vHealingwave.Available = FALSE;
				pVampirePlayer->vTimeAction = pVampirePlayer->vParamPlayer.vTimerGetElapsed + 0.3;
				return TRUE;
			}
		}
	}
	return FALSE;
}

// Передача бессметрия
bool fTransmissionOfImmortality(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
	if (pVampirePlayer->pPartner == NULL) FALSE; 
	if (pVampirePlayer->pPartner != NULL && pVampirePlayer->vTransmitInvulnerability == TRUE)
	{
		if (pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->vPickupItem == TRUE)
		{
			pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->vPickupItem = FALSE;
			pVampirePlayer->vVampire.vInventory.fRefreshInventory();
			pVampirePlayer->pPartner->vVampire.vInventory.fRefreshInventory();
			pVampirePlayer->vTransmitInvulnerability = FALSE;
			pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
			pVampirePlayer->vFlagIPassedInvulnerability = TRUE;
		}
		else
		{
			if (GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit) != ID_ORDER_DROPITEM)
			{
				pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = TRUE;
				if (UnitDropItemTarget(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
									   pVampirePlayer->vVampire.vInventory.fGetItem(ID_ITEM_IMMORTALITY),
									   pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit) == TRUE)
				{
					return TRUE;
				}
				pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
			}
			else
			{
				return TRUE;
			}
		}
	}
	return FALSE;
}

// Завершение атаки вампира
void fCompletingAVampireAttack(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	if (pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE && pDataVampires->vAttack == FALSE)
	{
		pVampirePlayer->vFarsight = TRUE;
		//pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.X = 0;
		//pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->CoordinatesForGoToGlobal.Y = 0;
		if (pVampirePlayer->pPartner == NULL ||
			(pVampirePlayer->pPartner != NULL &&
			pVampirePlayer->vFarmBase == pVampirePlayer->pPartner->vFarmBase &&
			pVampirePlayer->vParamPlayer.vAI == 10))
		{
			pDataVampires->fRefreshBaseFarsight(pVampirePlayer->vFarmBase);
			pDataVampires->fFreeFarsight();
			pDataVampires->fIlluminationOfBase(pVampirePlayer->vFarmBase);
			pVampirePlayer->vFarmBase = DO_NOT_FIND_BASE;
			if (pVampirePlayer->pPartner != NULL) pVampirePlayer->pPartner->vFarmBase = DO_NOT_FIND_BASE;
		}
		//if (GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit) == ID_ORDER_WAITING)
		//{
			pVampirePlayer->vVampire.vUnitParam.vAttack = FALSE;
		//}
	}
}

// Начало атаки вампира
void fTheBeginningOfTheVampireAttack(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	if (((pVampirePlayer->vFlagPullYourselfUp == TRUE &&
		pVampirePlayer->vStage >= 20) ||
		pVampirePlayer->vFlagPullYourselfUp == FALSE) &&
		pVampirePlayer->vStage >= 12 &&
		pVampirePlayer->vVampire.vUnitParam.vAttack == FALSE &&
		pDataVampires->vAttack == TRUE &&
		pDataVampires->pPutGlobal->vResult == 1)
	{
		if (pVampirePlayer->vSync == FALSE)
		{
			if (fSync(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit) == FALSE) goto m2;
			if (fCheckSync(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit) == FALSE) goto m2;
			pVampirePlayer->vSync = TRUE;
			if (pVampirePlayer->pPartner != NULL) pVampirePlayer->pPartner->vSync = TRUE;
		}
		pVampirePlayer->vVampire.vUnitParam.vAttack = TRUE;
		pVampirePlayer->vFarmBase = pDataVampires->vBaseHuman;
		if (pVampirePlayer->vParamPlayer.vTimerGetElapsed < 2*60) pVampirePlayer->vFarsight = FALSE;
	}
m2:;
}

// Просветить клиф левел
void fEnlightenCliffLevel(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	if (pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vRaisingClifLevel == TRUE &&
		((pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vTimerRaisingClifLevel) >= 1))
	{
		if (pDataVampires->fFreeFarsight() == TRUE &&
			pDataVampires->fAddCoordinatesForFarsight(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
			                                          pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y) == TRUE)
		{
			pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vRaisingClifLevel = FALSE;
		}
	}
}

// Просветить
bool fEnlighten(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
	if (pVampirePlayer->vVampire.vEnlightenment.Available == TRUE &&
		pVampirePlayer->fIlluminationOfGlobalStaсkFarsight(pDataVampires) == TRUE)
	{
		pVampirePlayer->vVampire.vEnlightenment.vTimeCast = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
		pVampirePlayer->vVampire.vEnlightenment.Available = FALSE;	
		return TRUE;
	}
	return FALSE;
}

// Включить бессмертие
bool fEnableImmortality(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
	if (GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_LIFE) <
		(GetUnitState(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit, UNIT_STATE_MAX_LIFE) * 0.3) &&
		pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_IMMORTALITY) >= 1 &&
		(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeInvulnerability) >= 45)
	{
		pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = TRUE;
		if (UnitUseItem(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
			pVampirePlayer->vVampire.vInventory.fGetItem(ID_ITEM_IMMORTALITY)) == TRUE)
		{
			pVampirePlayer->vFlagIPassedInvulnerability = FALSE;
			pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
			pVampirePlayer->vTimeInvulnerability = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
			pVampirePlayer->vInvulnerability = TRUE;
			return TRUE;
		}
		pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
	}
}

// Сброс ошибок
void fResetErrors(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	/*if (pVampirePlayer->vVampire.vUnitParam.vAttack == FALSE &&
		pVampirePlayer->vParamPlayer.vStage >= 12 &&
		pDataVampires->vAttack == TRUE &&
		pDataVampires->vBaseHuman != DO_NOT_FIND_BASE &&
		pDataVampires->pPutGlobal->vStartThread == FALSE &&
		pVampirePlayer->vFarmBase == DO_NOT_FIND_BASE &&
		pVampirePlayer->vFlagStage11 == FALSE &&
		((pVampirePlayer->pPartner == NULL) ||
		(pVampirePlayer->pPartner != NULL &&
		pVampirePlayer->vFarmBase == pVampirePlayer->pPartner->vFarmBase &&
		pVampirePlayer->vFlagStage11 == pVampirePlayer->pPartner->vFlagStage11)))
	{
		if (pVampirePlayer->vSync == TRUE)
		{
			pVampirePlayer->vParamPlayer.vStage--;
			//fEndAttack();
		}
	}*/
	if (pVampirePlayer->vVampire.vUnitParam.vAttack == FALSE &&
		(pVampirePlayer->pPartner == NULL ||
		(pVampirePlayer->pPartner != NULL &&
		pVampirePlayer->pPartner->vVampire.vUnitParam.vAttack == FALSE)) &&
		pDataVampires->vAttack == TRUE &&
		pDataVampires->pPutGlobal->vStartThread == FALSE &&
		(pDataVampires->vBaseHuman != DO_NOT_FIND_BASE &&
		((pVampirePlayer->vSync == TRUE &&
		pDataVampires->pPutGlobal->vResult == 1) ||
		(pVampirePlayer->vSync == FALSE &&
		pDataVampires->pPutGlobal->vResult == 0))) ||
		(pDataVampires->vAttack == TRUE &&
		pDataVampires->vBaseHuman == DO_NOT_FIND_BASE &&
		(pVampirePlayer->vSync == TRUE &&
		pDataVampires->pPutGlobal->vResult == 0)))
	{
		fEndAttack();
		pVampirePlayer->vFarsight = TRUE;
	}
	if (pVampirePlayer->vFarmBase == DO_NOT_FIND_BASE && pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE)
	{
		pVampirePlayer->vVampire.vUnitParam.vAttack = FALSE;
	}
	if (pVampirePlayer->vVampire.vUnitParam.vAttack == FALSE &&
		pDataVampires->vBaseHuman == 0 &&
		pDataVampires->vAttack == FALSE)
	{
		pDataVampires->vBaseHuman = DO_NOT_FIND_BASE;
	}
	/*if (pVampirePlayer->pPartner != NULL &&
		pVampirePlayer->pPartner->vVampire.vUnitParam.vAttack == FALSE &&
		pDataVampires->vBaseHuman == 0 &&
		pDataVampires->vAttack == FALSE)
	{
		pDataVampires->vBaseHuman = DO_NOT_FIND_BASE;
	}*/
}

// Конец атаки
void fEndAttack()
{
	if (pDataVampires == NULL) return;
	pDataVampires->vAttack = FALSE;
	pDataVampires->vBaseHuman = DO_NOT_FIND_BASE;
	pDataVampires->vWall = FALSE;
	pDataVampires->vTiniGo = FALSE;
	pDataVampires->pPutGlobal->vStartThread = FALSE;
}

// Начальная стадия
void fInitialStage(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	if (pVampirePlayer->vFarmBase == 0 && pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE && pDataVampires->vAttack == FALSE)
	{
		if (pVampirePlayer->vVampire.vUnitParam.vTarget != 0)
		{
			pVampirePlayer->vVampire.vUnitParam.vHPTarget = GetUnitState(pVampirePlayer->vVampire.vUnitParam.vTarget, UNIT_STATE_LIFE);
			if (pVampirePlayer->vVampire.vUnitParam.vHPTarget <= 0)
			{
				pVampirePlayer->vVampire.vUnitParam.vTarget = 0;
			}
		}
		if ((pVampirePlayer->vVampire.vUnitParam.vTarget != 0 &&
			IsUnitVisible(pVampirePlayer->vVampire.vUnitParam.vTarget,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vPlayer) == FALSE) ||
			pVampirePlayer->vVampire.vUnitParam.vTarget == 0)
			// &&
			    /*UnitDamageTarget(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
						         pVampirePlayer->hGroupFarm,
								 1000,
								 TRUE,
								 TRUE,
								 ATTACK_TYPE_NORMAL,
								 DAMAGE_TYPE_UNKNOWN,
								 WEAPON_TYPE_WHOKNOWS) == FALSE)*/
		{
			pVampirePlayer->hGroupFarm = CreateGroup();
			GroupEnumUnitsInRect(pVampirePlayer->hGroupFarm,vBaseZeroRect,NULL);
			pVampirePlayer->vVampire.vUnitParam.vTarget = fGetNearestUnitEnemyForVampire(pVampirePlayer->hGroupFarm,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit);
			if (pVampirePlayer->vVampire.vUnitParam.vTarget != NULL)
			{
				if (IssueTargetOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,ID_ORDER_ATTACK,pVampirePlayer->vVampire.vUnitParam.vTarget) == TRUE);
			}
			else
			{
				if (fOrderToIdDataUnit(pVampirePlayer,
									   pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
									   ID_ORDER_MOVE,
									   vManaWell) == TRUE)
				{
					pVampirePlayer->vFarmBase = DO_NOT_FIND_BASE;
					pVampirePlayer->vVampire.vUnitParam.vAttack = FALSE;
				}
			}
			DestroyGroup(pVampirePlayer->hGroupFarm);
		}
	}
}

// Следующая просветка
void fTheNextEnlightenment(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	if (pVampirePlayer->vFarsight == TRUE)
	{
		if (pVampirePlayer->vVampire.vEnlightenment.Available == FALSE &&
			pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vVampire.vEnlightenment.vTimeCast >= pVampirePlayer->vVampire.vEnlightenment.CoolDown)
		{
			pVampirePlayer->vVampire.vEnlightenment.Available = TRUE;
			if (pDataVampires->fNoFarsightBase() == TRUE)
			{
				if (pDataVampires->fNoFarsightPlus() == TRUE)
				{
					if (pDataVampires->vCountFarsight >= (vMaxBase + 36 + 3))
					{
						pDataVampires->fRefreshAllFarsight();
					}
					else
					{
						pVampirePlayer->vFlagFarsight = 2;
					}
				}
				else
				{
					pVampirePlayer->vFlagFarsight = 1;
				}
			}
		}
		if (pVampirePlayer->vVampire.vEnlightenment.Available == TRUE && pDataVampires->vQFarsight == 0)
		{
			pDataVampires->fNextBaseFarsight(pVampirePlayer->vFlagFarsight);
		}
	}
}

// Убить инферналов
bool fKillInfernals(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
	if (pDataVampires->vKillInfernals == TRUE)
	{
		pVampirePlayer->vIdOrder = GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit);
		if (pVampirePlayer->vIdOrder == ID_ORDER_ATTACK) return FALSE;
		pVampirePlayer->hGroupFarm = CreateGroup();
		GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
							  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
							  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
							  128*36,Filter(&fFilterInfernal));
		pVampirePlayer->u = fGetNearestUnit(pVampirePlayer->hGroupFarm,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit);
		DestroyGroup(pVampirePlayer->hGroupFarm);
		if (pVampirePlayer->u != 0 &&
			IssueTargetOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
								 ID_ORDER_ATTACK,
								 pVampirePlayer->u) == TRUE)
		{
			return TRUE;
		}
	}
	return FALSE;
}
// Просветить вал
bool fEnlightenWall(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
	if (pDataVampires->vWall == FALSE) return FALSE;
	if (pDataVampires->vFalgNextBase == FALSE &&
		pVampirePlayer->vVampire.vEnlightenment.Available == TRUE)
	{
		pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vRaisingClifLevel = TRUE;
		fEnlightenCliffLevel(pVampirePlayer);
		if (fEnlighten(pVampirePlayer) == TRUE)
		{
			pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vTimerRaisingClifLevel = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
			if (pVampirePlayer->pPartner != NULL)
			{
				pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->vTimerRaisingClifLevel = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
			}
			goto m1;
		}
	}
	return FALSE;
m1:
	return TRUE;
}

void fActionsVampire(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer->vTimeAction > pVampirePlayer->vParamPlayer.vTimerGetElapsed) return;
	// Обнуляем разрешение
	fResetTheResolution(pVampirePlayer);
	pVampirePlayer->vStage = pVampirePlayer->vParamPlayer.vStage;
	//pVampirePlayer->vParamPlayer.vBusy = TRUE;
	if (pVampirePlayer->vStage >= 4)
	{
	fAddDataUnitInRange(pVampirePlayer,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit);
	// Возвращаемся после отступления
	fWeReturnAfterTheRetreat(pVampirePlayer);
	// Стелс
	if (fStealth(pVampirePlayer) == TRUE) goto m1;
	// Лечение
	if (fTreatment(pVampirePlayer) == TRUE) goto m1;
	// Передача бессметрия
	if (fTransmissionOfImmortality(pVampirePlayer) == TRUE) goto m1;
	// Завершение атаки вампира
    fCompletingAVampireAttack(pVampirePlayer);
	//if (pVampirePlayer->pPartner != NULL) fCompletingAVampireAttack(pVampirePlayer->pPartner);
	// Начало атаки вампира
	fTheBeginningOfTheVampireAttack(pVampirePlayer);
	//
	if (fEnlightenWall(pVampirePlayer) == TRUE) goto m1;
	// Просветить клиф левел
	fEnlightenCliffLevel(pVampirePlayer);
	// Просветить
	if (fEnlighten(pVampirePlayer) == TRUE)
	{
		pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vTimerRaisingClifLevel = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
		if (pVampirePlayer->pPartner != NULL)
		{
			pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->vTimerRaisingClifLevel = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
		}
		if (pDataVampires->vBaseHuman == JASS_PATH_BLIGHT)
			pDataVampires->vBaseHuman = 0;
		goto m1;
	}
	// Включить бессмертие
	if (fEnableImmortality(pVampirePlayer) == TRUE) goto m1;
	// Удаляем голд коин если баг(если триггер на удаление не сработал)
	if (pVampirePlayer->vGoldCoin != 0 &&
		pVampirePlayer->vTimeDelGoldCoin != 0 &&
		(pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeDelGoldCoin > 5))
	{
		RemoveItem(pVampirePlayer->vGoldCoin);
		pVampirePlayer->vGoldCoin = 0;
		pVampirePlayer->vTimeDelGoldCoin = 0;
	}
	// Берём голд коин
	if (pVampirePlayer->vParamPlayer.vTimerGetElapsed - pVampirePlayer->vTimeGoldCoin > 3)
	if (fVampireGetGoldCoin(pVampirePlayer) == TRUE)
	{
		pVampirePlayer->vGoldCoin = LoadItemHandle(vHT,pVampirePlayer->vParamPlayer.vTimerPlayer,CONST_GOLD_COIN);
		pVampirePlayer->vTimeGoldCoin = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
		if (pVampirePlayer->vTimeDelGoldCoin == 0)
		{
			pVampirePlayer->vTimeDelGoldCoin = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
		}
		goto m1;
	}
	// Обнуляем таймер для удаления голд коина
	if (pVampirePlayer->vTimeDelGoldCoin != 0 &&
		pVampirePlayer->vGoldCoin == 0)
	{
		pVampirePlayer->vTimeDelGoldCoin = 0;
	}
	// Убить инферналов вокруг
	if (fKillInfernals(pVampirePlayer) == TRUE) goto m1;
	// Тактика вампира около вала
	if (fVampireTactics2(pVampirePlayer) == TRUE) goto m1;
	// Сброс ошибок
	fResetErrors(pVampirePlayer);
	// Начальная стадия
	fInitialStage(pVampirePlayer);
	// Возвращаемся в начале игры после фарма базы №0
	if (pVampirePlayer->vFarmBase == 0 && pVampirePlayer->vVampire.vUnitParam.vAttack == TRUE && pDataVampires->vAttack == FALSE)
	{
		if (pVampirePlayer->vParamPlayer.vTimerGetElapsed > 1.4 * 60)// ||
			//GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit) == ID_ORDER_WAITING)
		{
			if (fOrderToIdDataUnit(pVampirePlayer,
								   pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
								   ID_ORDER_MOVE,
								   vManaWell) == TRUE)
			{
				pVampirePlayer->vFarmBase = DO_NOT_FIND_BASE;
				pVampirePlayer->vVampire.vUnitParam.vAttack = FALSE;
			}
		}
	}
	// Следующая просветка
	fTheNextEnlightenment(pVampirePlayer);
	}
	if (pVampirePlayer->vVampire.vUnitParam.vAttack == FALSE &&
		pDataVampires->vBaseHuman != JASS_PATH_BLIGHT)
	if (pVampirePlayer->vStage >= 0 && pVampirePlayer->vStage <= 52)
	{
		switch(pVampirePlayer->vStage)
		{
		case 0:
			if (fCheckCreateIdDataUnit((unsigned short)pVampirePlayer->vParamPlayer.vAI) == TRUE)
				pVampirePlayer->vParamPlayer.vStage++;
			goto m1;
		case 1:
			if ((pVampirePlayer->vParamPlayer.vUnit[COMMENT_MAIN_VAMPIRE].vIdForComments != COMMENT_MAIN_VAMPIRE &&
				pVampirePlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_VAMPIRE1,COMMENT_MAIN_VAMPIRE) == true) ||
				(pVampirePlayer->vParamPlayer.vUnit[COMMENT_MAIN_VAMPIRE].vIdForComments != COMMENT_MAIN_VAMPIRE &&
				pVampirePlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_VAMPIRE2,COMMENT_MAIN_VAMPIRE) == true) ||
				(pVampirePlayer->vParamPlayer.vUnit[COMMENT_MAIN_VAMPIRE].vIdForComments != COMMENT_MAIN_VAMPIRE &&
				pVampirePlayer->vActionStackForUnits.fSetComment(COMMENT_NEW_UNIT,ID_UNIT_VAMPIRE3,COMMENT_MAIN_VAMPIRE) == true))
			{
				pVampirePlayer->vVampire.vUnitParam.pDataUnits = &vDataUnits[pVampirePlayer->vParamPlayer.vUnit[COMMENT_MAIN_VAMPIRE].vId];
				if (pVampirePlayer->vVampire.vUnitParam.pDataUnits != NULL)
				{
					if (pVampirePlayer->vVampire.vInventory.fInit(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit) == FALSE)
					{
						goto m1;
					}
					pVampirePlayer->vStealth = TRUE;
					pVampirePlayer->vHealingwave = TRUE;
					pVampirePlayer->vComeToMe = TRUE;
					//pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit = pVampirePlayer->vParamPlayer.vUnit[COMMENT_MAIN_VAMPIRE].pDataUnit;
					pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = TRUE;
					pVampirePlayer->vCoordinatesRC.X = fXCenter(ID_UNIT_VAMPIRIC_RC,(unsigned short)(250 + (pVampirePlayer->vParamPlayer.vAI - 10) * 4));
					pVampirePlayer->vCoordinatesRC.Y = fYCenter(ID_UNIT_VAMPIRIC_RC,(unsigned short)244);
					pVampirePlayer->vParamPlayer.vStage++;
				}
			}
			goto m1;
		case 2:
			if (pVampirePlayer->vRC != NULL)
			{
				goto m1;
			}
			if (IsUnitVisible(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->vPlayer) == TRUE &&
				IssuePointOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,ID_ORDER_PATROL,pVampirePlayer->vCoordinatesRC.X,pVampirePlayer->vCoordinatesRC.Y) == TRUE &&
				pVampirePlayer->vParamPlayer.vUnit[COMMENT_MAIN_VAMPIRE].pDataUnit &&
				UnitUseItemPoint(pVampirePlayer->vParamPlayer.vUnit[COMMENT_MAIN_VAMPIRE].pDataUnit->WhichUnit,
				UnitItemInSlot(pVampirePlayer->vParamPlayer.vUnit[COMMENT_MAIN_VAMPIRE].pDataUnit->WhichUnit,0),
				pVampirePlayer->vCoordinatesRC.X,
				pVampirePlayer->vCoordinatesRC.Y) == FALSE)
			{
				pVampirePlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 3:
			if (pVampirePlayer->vRC != NULL && pVampirePlayer->vParamPlayer.vTimerGetElapsed > 56)
			{
				pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->Permission = FALSE;
				fAddDataUnitInRange(pVampirePlayer,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit);
				if (fOrderToIdDataUnit(pVampirePlayer,
									   pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
									   ID_ORDER_MOVE,
									   vManaWell) == TRUE)
				{
					pVampirePlayer->vParamPlayer.vStage++;
				}
			}
			goto m1;
		case 4:
			if (GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit) == ID_ORDER_WAITING)
				pVampirePlayer->vParamPlayer.vStage++;
			goto m1;
		case 5:
			if (pVampirePlayer->vParamPlayer.vTimerGetElapsed > 56)
			{
				if (pVampirePlayer->pPartner != NULL)
				{
					pVampirePlayer->pPartner->vFarmBase = DO_NOT_FIND_BASE;
					if (pVampirePlayer->vParamPlayer.vAI == 10)
					{
						pDataVampires->fIlluminationOfBase(0);
						//pVampirePlayer->vVampire.vEnlightenment.vTimeCast = pVampirePlayer->vParamPlayer.vTimerGetElapsed;
						//pVampirePlayer->vVampire.vEnlightenment.Available = FALSE;
					}
				}
				else
				{
					pDataVampires->fIlluminationOfBase(0);
				}
				pVampirePlayer->vFarsight = TRUE;
				pVampirePlayer->vFlag = FALSE;
				pVampirePlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 6:
			if (pVampirePlayer->vParamPlayer.vAI == 10 &&
				pDataVampires->vQFarsight == 0 &&
				pVampirePlayer->vParamPlayer.vTimerGetElapsed > 58)
			{
				pVampirePlayer->hGroupFarm = CreateGroup();
				GroupEnumUnitsInRect(pVampirePlayer->hGroupFarm,vBaseZeroRect,NULL);
				pVampirePlayer->vVampire.vUnitParam.vTarget = fGetNearestUnitEnemyForVampire(pVampirePlayer->hGroupFarm,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit);
				if (pVampirePlayer->vVampire.vUnitParam.vTarget != NULL)
				{
					if (IssueTargetOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,ID_ORDER_ATTACK,pVampirePlayer->vVampire.vUnitParam.vTarget) == TRUE)
					{
						pVampirePlayer->vVampire.vUnitParam.vAttack = TRUE;
						//GroupEnumUnitsInRect(pVampirePlayer->hGroupFarm,vBaseZeroRect,NULL);
						pVampirePlayer->vFarmBase = 0;
					}
				}
				pVampirePlayer->vFlag = TRUE;
				DestroyGroup(pVampirePlayer->hGroupFarm);
				pVampirePlayer->hGroupFarm = NULL;
			}
			if (pDataVampires->vQFarsight == 0 &&
				(pVampirePlayer->vFlag == TRUE ||
				(pVampirePlayer->pPartner != NULL &&
				pVampirePlayer->pPartner->vFlag == TRUE)))
			{
				pVampirePlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 7:
			if (pVampirePlayer->vParamPlayer.vTimerGetElapsed > 1.5 * 60 && GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 25)
			{
				pVampirePlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 8:
			if (pVampirePlayer->pPartner != NULL)
			{
				if (pVampirePlayer->vParamPlayer.vAI == 10)
				{
					if (fTransferRes(pVampirePlayer->vParamPlayer.vPlayer,pVampirePlayer->pPartner->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD, 25 - 4) == FALSE)
					{
						goto m1;
					}
					pVampirePlayer->vShop = vTopShop;
					pVampirePlayer->vParamPlayer.vStage++;
				}
				if (pVampirePlayer->vParamPlayer.vAI == 11)
				{
					if (pDataVampires->vActionStackForUnitsEnemy.fGetQuantityUnits(ID_UNIT_WORKER) >= 15 &&
						pDataVampires->vActionStackForUnitsEnemy.fGetQuantityUnits(ID_UNIT_BUILD_GRADE_TENT) >= 1 &&
						(pDataVampires->vActionStackForUnitsEnemy.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_WHITE) >= 4 ||
						pDataVampires->vActionStackForUnitsEnemy.fGetQuantityUnits(ID_UNIT_BUILD_TOWER_GOLD) >= 4))
					{
						pVampirePlayer->vTactic = 2;
					}
					else
					{
						pVampirePlayer->vTactic = 1;
					}
					pVampirePlayer->vShop = vBansha;
					pVampirePlayer->vParamPlayer.vStage++;
				}
			}
			goto m1;
		case 9:
			pVampirePlayer->vG = fG(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
				                    vDataUnits[pVampirePlayer->vShop].pDataUnit->LastCoordinates.X,vDataUnits[pVampirePlayer->vShop].pDataUnit->LastCoordinates.Y);
			if (pVampirePlayer->vG > 128 *2)
			{
				pVampirePlayer->vIdOrder = GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit);
				if (pVampirePlayer->vIdOrder != ID_ORDER_MOVE)
				if (fOrderToIdDataUnit(pVampirePlayer,
								       pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
									   ID_ORDER_MOVE,
									   pVampirePlayer->vShop) == TRUE);
			}
			else
			{
				pVampirePlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 10:
			if (pVampirePlayer->vShop != 0)
			{
				if (pVampirePlayer->vParamPlayer.vAI == 10 && pVampirePlayer->vShop == vTopShop)
				{
					if (GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 4 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 2 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE)
					{
						/*if (GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 8 &&
							pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 4 &&
							fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
							fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
							fBuyItem(pVampirePlayer->vShop,ID_ITEM_BEAST_SCROLL,&pVampirePlayer->vVampire.vInventory) == TRUE &&
							fBuyItem(pVampirePlayer->vShop,ID_ITEM_BEAST_SCROLL,&pVampirePlayer->vVampire.vInventory) == TRUE);*/
						if (fTransferRes(pVampirePlayer->vParamPlayer.vPlayer,pVampirePlayer->pPartner->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD,
							GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD)) == FALSE);
						pVampirePlayer->vShop = 0;
						pVampirePlayer->vParamPlayer.vStage++;
						goto m1;
					}
				}
				if (pVampirePlayer->vParamPlayer.vAI == 11 && pVampirePlayer->vShop == vBansha &&
					pVampirePlayer->pPartner->vShop == 0)
				{
					if ((pVampirePlayer->vTactic == 2 &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 15 &&
						fBuyAUnit(pVampirePlayer->vShop,ID_UNIT_TINI,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						fBuyAUnit(pVampirePlayer->vShop,ID_UNIT_TINI,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						fBuyAUnit(pVampirePlayer->vShop,ID_UNIT_TINI,&pVampirePlayer->vVampire.vInventory) == TRUE) ||
						(pVampirePlayer->vTactic == 1 &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 5 &&
						fBuyAUnit(pVampirePlayer->vShop,ID_UNIT_TINI,&pVampirePlayer->vVampire.vInventory) == TRUE))
					{
						fAddDataUnitInRange(pVampirePlayer);
						pVampirePlayer->vShop = vBaseOfUnits;
						pVampirePlayer->vParamPlayer.vStage--;
						goto m1;
					}
				}
				if (pVampirePlayer->vParamPlayer.vAI == 11 && pVampirePlayer->vShop == vBaseOfUnits &&
					pVampirePlayer->pPartner->vShop == 0)
				{
					if ((pVampirePlayer->vTactic == 2 &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 20 &&
						fBuyAUnit(pVampirePlayer->vShop,ID_UNIT_INFERNAL,&pVampirePlayer->vVampire.vInventory) == TRUE) ||
						(pVampirePlayer->vTactic == 1 &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 40 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_IMMORTALITY,&pVampirePlayer->vVampire.vInventory) == TRUE))
					{
						fAddDataUnitInRange(pVampirePlayer);
						if (GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 12)
						{
							pVampirePlayer->vShop = vTopShop;
							pVampirePlayer->vParamPlayer.vStage--;
							goto m1;
						}
						pVampirePlayer->vShop = 0;
						pVampirePlayer->vParamPlayer.vStage++;
						goto m1;
					}
				}
				if (pVampirePlayer->vParamPlayer.vAI == 11 && pVampirePlayer->vShop == vTopShop &&
					pVampirePlayer->pPartner->vShop == 0)
				{
					if (GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 12 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 12 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 12 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 12 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 12 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BEAST_SCROLL,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 12 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BEAST_SCROLL,&pVampirePlayer->vVampire.vInventory) == TRUE);
						pVampirePlayer->vShop = 0;
						pVampirePlayer->vParamPlayer.vStage++;
						goto m1;
				}
			}
			goto m1;
		case 11:
			pVampirePlayer->vFlagStage11 = TRUE;
			if (pDataVampires->vAttack == TRUE)
			{
				pVampirePlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (fGoToGlobalBase(pVampirePlayer) == TRUE)
			{
				pVampirePlayer->vParamPlayer.vStage++;
				goto m1;
			}
			goto m1;
		case 12:
			if (pVampirePlayer->vFlagStage11 == TRUE)
			{
				pVampirePlayer->vFlagStage11 = FALSE;
			}
			if ((GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 50) ||
				(pVampirePlayer->pPartner != NULL &&
				(GetPlayerState(pVampirePlayer->pPartner->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 50)))
			{
				pDataVampires->vKillInfernals = TRUE;
				pVampirePlayer->vParamPlayer.vStage++;
				goto m1;
			}
			pVampirePlayer->vBaseHumanTemp = pDataVampires->vActionStackForUnitsEnemy.fFindBase();
			if (pVampirePlayer->vBaseHumanTemp != pDataVampires->vBaseHuman)
			{
				pDataVampires->vKillInfernals = TRUE;
			}
			if (pDataVampires->vAttack == FALSE)
			{
				pVampirePlayer->vParamPlayer.vStage--;
			}
			goto m1;
		case 13:
			if (pVampirePlayer->pPartner != NULL)
			{
				if (pVampirePlayer->vParamPlayer.vAI == 10 &&
					pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_IMMORTALITY) == 0 &&
					pVampirePlayer->pPartner->vVampire.vInventory.fQItems(ID_ITEM_IMMORTALITY) == 0)
				{
					if	(GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 50)
					{
						pVampirePlayer->vComeToMe = FALSE;
						pVampirePlayer->pPartner->vComeToMe = FALSE;
						pVampirePlayer->vFlagPullYourselfUp = TRUE;
						pVampirePlayer->vVampire.vUnitParam.vAttack = FALSE;
						pVampirePlayer->vParamPlayer.vStage++;
					}
					else
					{
						if (fTransferRes(pVampirePlayer->pPartner->vParamPlayer.vPlayer,pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD,
							GetPlayerState(pVampirePlayer->pPartner->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD)) == FALSE);
					}
				}
				else
				{
					pVampirePlayer->vParamPlayer.vStage = 20;
				}
				if (pVampirePlayer->vParamPlayer.vAI == 11)
				{
					pVampirePlayer->vParamPlayer.vStage = 20;
					goto m1;
				}
			}
			else
			{
				pVampirePlayer->vBaseHumanTemp = pDataVampires->vActionStackForUnitsEnemy.fFindBase();
				if (pVampirePlayer->vBaseHumanTemp != pDataVampires->vBaseHuman)
				{
					pVampirePlayer->vComeToMe = FALSE;
					pVampirePlayer->vParamPlayer.vStage++;
				}
				else
				{
					pVampirePlayer->vParamPlayer.vStage = 20;
				}
			}
			goto m1;
		case 14:
			if (fOrderToIdDataUnit(pVampirePlayer,
								   pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
								   ID_ORDER_PATROL,
								   vBaseOfUnits) == TRUE);
				pVampirePlayer->vParamPlayer.vStage++;
			goto m1;
		case 15:
			pVampirePlayer->vG = fG(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
									pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
				                    vDataUnits[vBaseOfUnits].pDataUnit->LastCoordinates.X,
									vDataUnits[vBaseOfUnits].pDataUnit->LastCoordinates.Y);
			if (pVampirePlayer->vG < 128 * 2)
			{
				pVampirePlayer->vShop = vBaseOfUnits;
				IssueImmediateOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,0);
				pVampirePlayer->vParamPlayer.vStage++;
			}
			else
			{
				if (pVampirePlayer->vIdOrder != ID_ORDER_PATROL)
				if (fOrderToIdDataUnit(pVampirePlayer,
									   pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
									   ID_ORDER_PATROL,
									   vBaseOfUnits) == TRUE);
			}
			goto m1;
		case 16:
			if (GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) < 8 ||
				pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_BREEZE) <= 0)
				pVampirePlayer->vParamPlayer.vStage += 2;
			pVampirePlayer->vG = fG(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
									pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
				                    pVampirePlayer->vRC->LastCoordinates.X,
									pVampirePlayer->vRC->LastCoordinates.Y);
			if (pVampirePlayer->vG > 128 *1)
			{
				pVampirePlayer->vIdOrder = GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit);
				if (pVampirePlayer->vIdOrder != ID_ORDER_MOVE)
				if (IssueTargetOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
										 ID_ORDER_MOVE,
										 pVampirePlayer->vRC->WhichUnit) == TRUE);
			}
			else
			{
				pVampirePlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 17:
			pVampirePlayer->vIdOrder = GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit);	
			if (pVampirePlayer->vIdOrder != ID_ORDER_DROPITEM &&
				pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_BREEZE) >= 1 &&
				UnitDropItemTarget(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,
								   pVampirePlayer->vVampire.vInventory.fGetItem(ID_ITEM_BREEZE),
								   pVampirePlayer->vRC->WhichUnit) == TRUE)
			{
				pVampirePlayer->vVampire.vInventory.fRefreshInventory();
				pVampirePlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pVampirePlayer->vVampire.vInventory.fQItems(ID_ITEM_BREEZE) == 0)
			{
				pVampirePlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 18:
			pVampirePlayer->vG = fG(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
									pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
				                    vDataUnits[pVampirePlayer->vShop].pDataUnit->LastCoordinates.X,
									vDataUnits[pVampirePlayer->vShop].pDataUnit->LastCoordinates.Y);
			if (pVampirePlayer->vG > 128 *2)
			{
				pVampirePlayer->vIdOrder = GetUnitCurrentOrder(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit);
				if (pVampirePlayer->vIdOrder != ID_ORDER_MOVE)
				if (fOrderToIdDataUnit(pVampirePlayer,
									   pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit,
									   ID_ORDER_MOVE,
									   pVampirePlayer->vShop) == TRUE);
			}
			else
			{
				pVampirePlayer->vParamPlayer.vStage++;
			}
			goto m1;
		case 19:
			if (pVampirePlayer->vShop != 0)
			{
				if (pVampirePlayer->vParamPlayer.vAI == 10 && pVampirePlayer->vShop == vTopShop)
				{
					if (GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 2 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						pVampirePlayer->vVampire.vInventory.fRefreshInventory() == TRUE &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 2 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						pVampirePlayer->vVampire.vInventory.fRefreshInventory() == TRUE &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 2 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						pVampirePlayer->vVampire.vInventory.fRefreshInventory() == TRUE &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 2 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BREEZE,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						pVampirePlayer->vVampire.vInventory.fRefreshInventory() == TRUE &&
						GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 2 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_BEAST_SCROLL,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						pVampirePlayer->vVampire.vInventory.fRefreshInventory() == TRUE);
					pVampirePlayer->vShop = 0;
					pVampirePlayer->vParamPlayer.vStage++;
					goto m1;
				}
				/*if (pVampirePlayer->vParamPlayer.vAI == 10 && pVampirePlayer->vShop == vBansha)
				{
					if (GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 15 &&
						fBuyAUnit(pVampirePlayer->vShop,ID_UNIT_TINI,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						fBuyAUnit(pVampirePlayer->vShop,ID_UNIT_TINI,&pVampirePlayer->vVampire.vInventory) == TRUE &&
						fBuyAUnit(pVampirePlayer->vShop,ID_UNIT_TINI,&pVampirePlayer->vVampire.vInventory) == TRUE)
					{
						pVampirePlayer->vShop = vBaseOfUnits;
						pVampirePlayer->vParamPlayer.vStage--;
						goto m1;
					}
				}*/
				if (pVampirePlayer->vParamPlayer.vAI == 10 &&
					pVampirePlayer->vShop == vBaseOfUnits)
				{
					if (GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 40 &&
						pVampirePlayer->vVampire.vInventory.vQFreeSlots() >= 1 &&
						fBuyItem(pVampirePlayer->vShop,ID_ITEM_IMMORTALITY,&pVampirePlayer->vVampire.vInventory) == TRUE)
					{
						if (GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 2)
						{
							pVampirePlayer->vShop = vTopShop;
							pVampirePlayer->vParamPlayer.vStage--;
							goto m1;
						}
						pVampirePlayer->vShop = 0;
						pVampirePlayer->vParamPlayer.vStage++;
						goto m1;
					}
				}
			}
			goto m1;
		case 20:
			pVampirePlayer->vFlagStage11 = TRUE;
			if (pDataVampires->vAttack == TRUE &&
				pDataVampires->pPutGlobal != NULL &&
				pDataVampires->pPutGlobal->vResult == 1)
			{
				pVampirePlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (fGoToGlobalBase(pVampirePlayer) == TRUE)
			{
				pVampirePlayer->vParamPlayer.vStage++;
				goto m1;
			}
			goto m1;
		case 21:
			if (pVampirePlayer->vFlagStage11 == TRUE)
			{
				pVampirePlayer->vFlagStage11 = FALSE;
			}
			if ((pVampirePlayer->pPartner == NULL &&
				GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) >= 250) ||
				(pVampirePlayer->pPartner != NULL &&
				((GetPlayerState(pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD) +
				GetPlayerState(pVampirePlayer->pPartner->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD)) >= 250) &&
				fTransferRes(pVampirePlayer->pPartner->vParamPlayer.vPlayer,pVampirePlayer->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD,
					         GetPlayerState(pVampirePlayer->pPartner->vParamPlayer.vPlayer,PLAYER_STATE_RESOURCE_GOLD)) == TRUE))
			{
				pVampirePlayer->vParamPlayer.vStage++;
				goto m1;
			}
			if (pDataVampires->vAttack == FALSE)
			{
				pVampirePlayer->vParamPlayer.vStage--;
			}
			goto m1;
		case 22:
			if (pVampirePlayer->vParamPlayer.vResearch[N_RESEARCH_GEM1] == FALSE &&
				pVampirePlayer->vRC->Researching == FALSE)
			{
				fTrainActionResearch(&pVampirePlayer->vParamPlayer,pVampirePlayer->vRC,N_RESEARCH_SKILL_STRENGTH);
				pVampirePlayer->vParamPlayer.vStage--;
			}
			goto m1;
		case 100:
			if (fGoToAction(pVampirePlayer->vParamPlayer.vUnit[COMMENT_MAIN_VAMPIRE].vId,fConvertXYToI(4,30),ACTION_GO) == 1)
				pVampirePlayer->vParamPlayer.vStage++;
			goto m1;
		}
	}
m1:;
	//pVampirePlayer->vParamPlayer.vBusy = FALSE;
}

bool fGoToGlobalBase(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return FALSE;
			if (pDataVampires->vAttack == FALSE &&
				pDataVampires->vBaseHuman == DO_NOT_FIND_BASE &&
				pDataVampires->pPutGlobal->vStartThread == FALSE &&
				((pVampirePlayer->pPartner == NULL &&
				pVampirePlayer->vVampire.vUnitParam.vAttack == FALSE) ||
				(pVampirePlayer->pPartner != NULL &&
				pVampirePlayer->vVampire.vUnitParam.vAttack == FALSE &&
				pVampirePlayer->pPartner->vVampire.vUnitParam.vAttack == FALSE)))
			{
				pVampirePlayer->vFarsight = TRUE;
				pDataVampires->pPutGlobal->vResult = 0;
				//
				pDataVampires->vBaseHuman = fFindBaseByDataUnitNoEnemy(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit);
m10:
				if (pDataVampires->vBaseHuman == 0)
				{
					pDataVampires->vBaseHuman = pDataVampires->vActionStackForUnitsEnemy.fFindBase();
				}
				if (pDataVampires->vFalgNextBase == TRUE)
				{
					pDataVampires->vBaseHuman = fFindBaseNext(pVampirePlayer,pDataVampires->vBaseHuman);
					/*if (pDataVampires->vBaseHuman == 0)
					{
						return FALSE;
					}*/
					pDataVampires->vFalgNextBase = FALSE;
					goto m12;
				}
				if (pDataVampires->vBaseHuman != DO_NOT_FIND_BASE)
				{
					pDataVampires->vTypeBazeOneCell = FALSE;
					for (pVampirePlayer->vvi = 0; pVampirePlayer->vvi < vCountHumans; pVampirePlayer->vvi++)
					{
						if (pHumanPlayerGlobal[pVampirePlayer->vvi].vBase.vNBase == pDataVampires->vBaseHuman &&
							pHumanPlayerGlobal[pVampirePlayer->vvi].vBase.vMainWall->vQObstacles > 0)
						{
							pDataVampires->vTypeBazeOneCell = TRUE;
							break;
						}
					}
				}
				if (pDataVampires->vTypeBazeOneCell == TRUE &&
					(pVampirePlayer->vParamPlayer.vTimerGetElapsed < (60 * 5)))
				{
					pDataVampires->vBaseHuman = fFindBaseBig(pVampirePlayer);
					if (pDataVampires->vBaseHuman == 0 ||
						pDataVampires->vBaseHuman == DO_NOT_FIND_BASE)
					{
						pDataVampires->vBaseHuman = JASS_PATH_BLIGHT;
						pVampirePlayer->vInt3 = fConvertXYToI(256,244);
						goto m11;
					}
				}
				if (pDataVampires->vBaseHuman == DO_NOT_FIND_BASE)
				{
					return FALSE;
				}
				/*if (pDataVampires->vBaseHuman == 1)
				{
					pDataVampires->vTypeBazeOneCell = TRUE;
				}*/
m12:
				pVampirePlayer->vInt3 = vSizeMap;
m11:
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_BUILD_TOWER_GOLD,pDataVampires->vBaseHuman);
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_BUILD_TOWER_WHITE,pDataVampires->vBaseHuman);
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_BUILD_SLAYER_TAVERN,pDataVampires->vBaseHuman);
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_WORKER,pDataVampires->vBaseHuman);
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_BUILD_DOM,pDataVampires->vBaseHuman);
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_BUILD_GRADE_TENT,pDataVampires->vBaseHuman);
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_BUILD_TENT,pDataVampires->vBaseHuman);
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_SLAYER1,pDataVampires->vBaseHuman);
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_SLAYER2,pDataVampires->vBaseHuman);
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_MAIN_HUMAN1,pDataVampires->vBaseHuman);
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					pVampirePlayer->vInt3 = pDataVampires->vActionStackForUnitsEnemy.fFindInt(ID_UNIT_MAIN_HUMAN2,pDataVampires->vBaseHuman);
				}
				if (pDataVampires->vDansePool == FALSE &&
					pDataVampires->vBaseHuman == JASS_DANCEPOOL)
				{
					pDataVampires->vDansePool = TRUE;
					//pVampirePlayer->vInt3 = fFindIToMap(JASS_DANCEPOOL) - 50;
					pDataVampires->vBaseHuman = 0;
					goto m10;
				}
				if (pVampirePlayer->vInt3 == vSizeMap)
				{
					if (pDataVampires->vBaseHuman == 0)
					{
						return FALSE;
					}
					pDataVampires->vBaseHuman = 0;
					goto m10;
				}
				if (pVampirePlayer->vInt3 != vSizeMap &&
					pDataVampires->vBaseHuman != DO_NOT_FIND_BASE &&
					pDataVampires->vAttack == FALSE &&
					fGlobalGoToInt(pVampirePlayer->vInt3,
								   pDataVampires->pPutGlobal,
								   pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit) == TRUE)
				{
					if (fFreeSync(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit) == FALSE);
					pDataVampires->pPutGlobal->vStartThread = TRUE;
					pVampirePlayer->vSync = FALSE;
					if (pVampirePlayer->pPartner != NULL) pVampirePlayer->pPartner->vSync = FALSE;
					// После синхронизировать данные
					pDataVampires->vAttack = TRUE;
					return TRUE;
				}
				else
				{
					pDataVampires->vBaseHuman = DO_NOT_FIND_BASE;
				}
			}
	return FALSE;
}

void fGameVampire()
{
	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();
			}
		}
	}
	VampirePlayer *pVampirePlayer;
	pVampirePlayer = NULL;
	pVampirePlayer = (VampirePlayer *)LoadInteger(vHT,t,CONST_AI_PLAYER);
	if (pVampirePlayer == NULL) return;
	//pVampirePlayer->vParamPlayer.vTimerPlayer = t;
	pVampirePlayer->vParamPlayer.vTimerGetElapsed = vTimerGetElapsed;
	//pVampirePlayer = fGetVampirePlayer(t);
	if (!pVampirePlayer)
	{
		return;
	}
	if (pVampirePlayer->vParamPlayer.vBusy == TRUE)
	{
		return;
	}
	if (pVampirePlayer->vStage >= 2)
	{
	if (pVampirePlayer->pPartner != NULL &&
		vDataUnits[pVampirePlayer->pPartner->vParamPlayer.vAI].pDataUnit == NULL)
	{
		if (pVampirePlayer->pPartner->vParamPlayer.vTimerPlayer > 0)
		{
			DestroyTimer(pVampirePlayer->pPartner->vParamPlayer.vTimerPlayer);
		}
		pVampirePlayer->pPartner->vParamPlayer.vTimerPlayer = NULL;
		pVampirePlayer->pPartner = NULL;
		IssueImmediateOrderById(pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,0);
		return;
	}
	if (vDataUnits[pVampirePlayer->vParamPlayer.vAI].pDataUnit == NULL)
	{
		if (pVampirePlayer->vParamPlayer.vTimerPlayer > 0)
		{
			DestroyTimer(pVampirePlayer->vParamPlayer.vTimerPlayer);
		}
		pVampirePlayer->vParamPlayer.vTimerPlayer = NULL;
		pVampirePlayer->pPartner->pPartner = NULL;
		IssueImmediateOrderById(pVampirePlayer->pPartner->vVampire.vUnitParam.pDataUnits->pDataUnit->WhichUnit,0);
		return;
	}
	fInitTroopsVampire(pVampirePlayer);
	//fActionsUnits(&pVampirePlayer->vActionStackForUnits);
	fSkillVampire(&pVampirePlayer->vVampire,0);
	}
	fActionsVampire(pVampirePlayer);
	fActionsTini(pVampirePlayer);
	fActionsInfernal(pVampirePlayer);
}

void fAddDataUnitInRange(VampirePlayer *pVampirePlayer)
{
	if (pVampirePlayer == NULL) return;
	return;
							pVampirePlayer->hGroupFarm = CreateGroup();
							GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
												  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.X,
												  pVampirePlayer->vVampire.vUnitParam.pDataUnits->pDataUnit->LastCoordinates.Y,
												  128*5,NULL);
							do
							{
								pVampirePlayer->u = FirstOfGroup(pVampirePlayer->hGroupFarm);
								if (pVampirePlayer->u != 0)
								{
									pVampirePlayer->pDataUnit = fGetDataUnit(pVampirePlayer->u);
									if (pVampirePlayer->pDataUnit == NULL)
									{
										fCreateDataUnit(pVampirePlayer->u,THREAD_DO_NOT_MAIN);
									}
								}
								GroupRemoveUnit(pVampirePlayer->hGroupFarm,pVampirePlayer->u);
							}
							while (pVampirePlayer->u != 0);
							DestroyGroup(pVampirePlayer->hGroupFarm);
}

void fAddDataUnitInRange(VampirePlayer *pVampirePlayer, DataUnit *pDataUnit)
{
	if (pVampirePlayer == NULL || pDataUnit == NULL) return;
	pVampirePlayer->vId = GetUnitTypeId(pDataUnit->WhichUnit);
	if (pVampirePlayer->vId != 0)
	{
		if (pVampirePlayer->vId != pDataUnit->vId)
		{
			goto m5;
		}
		return;
	}
	if (pVampirePlayer->vId != 0) return;
m5:
							pVampirePlayer->hGroupFarm = CreateGroup();
							GroupEnumUnitsInRange(pVampirePlayer->hGroupFarm,
												  pDataUnit->LastCoordinates.X,
												  pDataUnit->LastCoordinates.Y,
												  128*16,
												  NULL);
							do
							{
								pVampirePlayer->u = FirstOfGroup(pVampirePlayer->hGroupFarm);
								if (pVampirePlayer->u != 0)
								{
									pVampirePlayer->pDataUnit = fGetDataUnit(pVampirePlayer->u);
									pVampirePlayer->vId = GetUnitTypeId(pVampirePlayer->u);
									if (pVampirePlayer->pDataUnit == NULL &&
										pVampirePlayer->vId == pDataUnit->vId &&
										GetOwningPlayer(pVampirePlayer->u) == pDataUnit->vPlayer)
									{
										pDataUnit->WhichUnit = pVampirePlayer->u;
										sprintf(pDataUnit->vKeyUnit,"%d\0",pDataUnit->WhichUnit);
										/*if (pDataUnit->vGoTo == TRUE)
										{
											FlushGameCache(pDataUnit->vSyncCache);
											pDataUnit->vSyncCache = InitGameCache(pDataUnit->vKeyUnit);
										}*/
										goto m1;
									}
								}
								GroupRemoveUnit(pVampirePlayer->hGroupFarm,pVampirePlayer->u);
							}
							while (pVampirePlayer->u != 0);
							fDelDataUnit(pDataUnit->vIdDataUnit);
m1:
							DestroyGroup(pVampirePlayer->hGroupFarm);
}

bool fOrderToIdDataUnit(VampirePlayer *pVampirePlayer, DataUnit *pDataUnit, integer vOrder, unsigned short vIdDataUnit)
{
	if (pVampirePlayer == NULL || pDataUnit == NULL) return FALSE;
	if (vOrder == NULL) return FALSE;
	if (vIdDataUnit < 0 || vIdDataUnit >= MAX_COUNT_UNITS) return FALSE;
	//DataUnit * pDataUnit2 = vDataUnits[vIdDataUnit].pDataUnit;
	fAddDataUnitInRange(pVampirePlayer,pDataUnit);
	if (IssuePointOrderById(pDataUnit->WhichUnit,
						    vOrder,
							vDataUnits[vIdDataUnit].pDataUnit->LastCoordinates.X,
		                    vDataUnits[vIdDataUnit].pDataUnit->LastCoordinates.Y) == TRUE)
	{
		pDataUnit->LastCoordinates.X = GetUnitX(pDataUnit->WhichUnit);
		pDataUnit->LastCoordinates.Y = GetUnitY(pDataUnit->WhichUnit);
		return TRUE;
	}
	return FALSE;
}

unsigned short fFindBaseNext(VampirePlayer *pVampirePlayer, unsigned short vBaseNo)
{
	unsigned short vBase;
	StackForUnits *current = pDataVampires->vActionStackForUnitsEnemy.first;
	while (current && (unsigned int)current != 0xdddddddd)
	{
		if (current->vIdDataUnit2.pDataUnit)
		{
			if (fIsFirstTower(current->vIdDataUnit2.pDataUnit->vId) == TRUE)
			{
				vBase = fFindBaseByDataUnit(current->vIdDataUnit2.pDataUnit);
				if (vBase >= 1 && vBase <= vMaxBase &&
					vBaseNo != vBase)
				{
					return vBase;
				}
			}
		}
		current = current->next;
	}
	return 0;
}

unsigned short fFindBaseBig(VampirePlayer *pVampirePlayer)
{
	unsigned short vBase;
	unsigned short vMaxQ;
	//unsigned short *vQUnitsInBase;
	//vQUnitsInBase = (unsigned short*)malloc(sizeof(unsigned short)*(vMaxBase+1));
	StackForUnits *current = pDataVampires->vActionStackForUnitsEnemy.first;
	StackForUnits *next = NULL;
	//memset(vQUnitsInBase,0,sizeof(unsigned short)*(vMaxBase+1));
	//vQUnitsInBase = new unsigned short[vMaxBase+1];
	for (int vvi = 0; vvi < vMaxBase+1; vvi++)
	{
		vQUnitsInBase[vvi] = 0;
	}
	while (current && (unsigned int)current != 0xdddddddd)
	{
		if (current->vIdDataUnit2.pDataUnit)
		{
			if (1)
			{
				vBase = fFindBaseByDataUnit(current->vIdDataUnit2.pDataUnit);
				if (vBase >= 1 && vBase <= vMaxBase)
					vQUnitsInBase[vBase]++;
				if (vBase == 0 ||
					vBase == JASS_SLAYERPLACE ||
					vBase == JASS_DANCEPOOL ||
					vBase == JASS_PATH_BLIGHT ||
					vBase == JASS_WATER_LEVEL_1 ||
					vBase == JASS_PATH_NOWATER)
					vQUnitsInBase[0]++;
			}
		}
		current = current->next;
	}
	vMaxQ = 0;
	vBase = DO_NOT_FIND_BASE;
	for (int vvi = 0; vvi <= vMaxBase; vvi++)
	{
		if (vMaxQ < vQUnitsInBase[vvi] &&
			vQUnitsInBase[vvi] != 0)
		{
			for (pVampirePlayer->vvi = 0; pVampirePlayer->vvi < vCountHumans; pVampirePlayer->vvi++)
			{
				if (pHumanPlayerGlobal[pVampirePlayer->vvi].vBase.vNBase == pDataVampires->vBaseHuman &&
					pHumanPlayerGlobal[pVampirePlayer->vvi].vBase.vMainWall->vQObstacles == 0)
				{
					vMaxQ = vQUnitsInBase[vvi];
					vBase = vvi;
					break;
				}
			}
		}
	}
	//free(vQUnitsInBase);
	//delete[] vQUnitsInBase;
	return vBase;
}