# atakB
if $ARGS[0] = 'atak':
	cla
	!!payment hit dodge
	poSp = speed * 20 / 100
	uvAg = agilV * 20 / 100
	poBox = react * 20 / 100
	uvBox = reactV * 20 / 100
	popad = rand(react - poBox, react + poBox) + rand(speed - poSp, speed + poSp) + bonusSh
	uvorot = rand(reactV - uvBox, reactV + uvBox) + rand(agilV - uvAg, agilV + uvAg)
	uvorKoef = uvorot * 50 / 100
	popKoef = popad * 50 / 100

	if popad > uvorot:
		if popad >= uvorot + uvorKoef:
			!!Crete, very direct hit
			'<b><font color="green">critical hits</font></b>'
			gs 'atakB', 'uronKrit'
		else
			!!normal hit
			!!attack the enemy
			'<b><font color="green">Contact</font></b>'
			gs 'atakB', 'uron'
		end
	else
		'<b><font color="red">is washed</font></b>'
	end
end

if $ARGS[0] = 'uronKrit':
	cla
	damDef = defence / 100
	damKoef = damDef * 20 / 100
	damage = rand(damDef + damKoef, damDef + damKoef * 2)
	gs 'atakB', 'damage'
end

if $ARGS[0] = 'uron':
	cla
	damDef = defence / 100
	damKoef = damDef * 20 / 100
	damage = rand(damDef - damKoef, damDef + damKoef)
	gs 'atakB', 'damage'
end

if $ARGS[0] = 'damage':
	cla

	if defenceV <= 0 and klonV <= 0 and unmaterialV <= 0 and barierV <= 0:
		if dospehV > 0:damageV -= dospehDefV & dospehEn -= 1
		if damage < 0:damage = 0

		healthV -= damage
		!!manna -= damageM

		if eleSh > 0:
			stunV = rand(eleSh, eleSh * 3)
			'<b><font color="green"><<$nameV>> paralyzed <<stunV>> rounds</font></b>'
		end

		'<b><font color="green">You have caused damage <<damage>> units</font></b>'
		!!'<b><font color="red">caused damage your manna <<damageM>> units</font></b>'

		if zerkaloV > 0:
			zerkaloV -= 1
			defence -= damage
			'<b><font color="red"><<$nameV>> reflected the damage and your defense has received <<damage>> points of damage</font></b>'
		end

		!!xgt 'fight', 'sta'
	end

	if defenceV > 0 and klonV <= 0 and unmaterialV <= 0:
		!!damSum = damage + damageM
		!!defence -= damSum
		defenceV -= damage
		'<b><font color="green">caused damage to your defense <<damage>> Protection of the enemy units</font></b>'
		!!xgt 'fight', 'sta'
	end

	if klonV > 0 and unmaterialV <= 0:
		klonV -= 1
		'<b><font color="green">Destroyed enemy clone</font></b>'
		!!xgt 'fight', 'sta'
	end

	if unmaterialV > 0:
		unmaterialV -= 1
		'<b><font color="red">Blow your protection passed through the body of the opponent. Opponents do not materials</font></b>'
		!!xgt 'fight', 'sta'
	end

	if barierV > 0:
		!!imeniteta barrier for damage
		if barierV >= damage:
			'<b><font color="red"><<$nameV>> easily withstood kick your protection</font></b>'
			!!xgt 'fight', 'sta'
		elseif barierV < damage:
			!!manna -= damageM
			!!health -= damage
			healthV -= damage

			if eleSh > 0:
				stunV = rand(eleSh, eleSh * 3)
				'<b><font color="green"><<$nameV>> paralyzed <<stunV>> rounds</font></b>'
			end

			'<b><font color="green">caused damage to your defense <<damage>> units</font></b>'
			!!'<b><font color="red">caused damage your manna <<damageM>> units</font></b>'

			if zerkaloV > 0:
				zerkaloV -= 1
				defence -= damage
				'<b><font color="red">Enemy reflected damage and your defense received <<damage>> points of damage</font></b>'
			end
		end

		!!xgt 'fight', 'sta'
	end
end

--- atakB ---------------------------------
