local g=_Tune.E_Horsepower/100 local E=_Tune.E_Torque/100 local X=_Tune.E_Trans1/1000 local b=_Tune.E_Trans2/1000 local l=_Tune.E_Redline/1000 function elecHP(E)E=E/1000 local z=1e-09 if E<=X then z=((E/X)^_Tune.EH_FrontMult/(1/g))*(E/X)+((E/X)^(1/_Tune.EH_FrontMult)/(1/g))*(1-E/X)elseif X<E and E<b then z=g elseif b<=E then z=g-((E-b)/(l-b))^_Tune.EH_EndMult/(1/(g*(_Tune.EH_EndPercent/100)))else error("\n\t \091\065\067\054\067\093\058 \068\114\105\118\101 \105\110\105\116\105\097\108\105\122\097\116\105\111\110 \102\097\105\108\101\100\033"..("\n\t    \065\110 \117\110\107\110\111\119\110 \101\114\114\111\114 \111\099\099\117\114\101\100 \119\104\101\110 \105\110\105\116\105\097\108\105\122\105\110\103 \101\108\101\099\116\114\105\099 \104\111\114\115\101\112\111\119\101\114\046"..("\n\t    \080\108\101\097\115\101 \115\101\110\100 \097 \115\099\114\101\101\110\115\104\111\116 \111\102 \116\104\105\115 \109\101\115\115\097\103\101 \116\111 \065\118\120\110\116\117\114\097\100\111\114\046"..("\n\t    \082\058 "..(E..("\044 \084\049\058 "..(X("\044 \084\050\058 ")..(b("\044 \076\058 ")..l("\046")))))))))end return z end function elecTQ(g)g=g/1000 local z=1e-09 if g<X then z=E elseif X<=g then z=E-((g-X)/(l-X))^_Tune.ET_EndMult/(1/(E*(_Tune.ET_EndPercent/100)))else error("\n\t \091\065\067\054\067\093\058 \068\114\105\118\101 \105\110\105\116\105\097\108\105\122\097\116\105\111\110 \102\097\105\108\101\100\033"..("\n\t    \065\110 \117\110\107\110\111\119\110 \101\114\114\111\114 \111\099\099\117\114\101\100 \119\104\101\110 \105\110\105\116\105\097\108\105\122\105\110\103 \101\108\101\099\116\114\105\099 \116\111\114\113\117\101\046"..("\n\t    \080\108\101\097\115\101 \115\101\110\100 \097 \115\099\114\101\101\110\115\104\111\116 \111\102 \116\104\105\115 \109\101\115\115\097\103\101 \116\111 \065\118\120\110\116\117\114\097\100\111\114\046"..("\n\t    \082\058 "..(g..("\044 \084\049\058 "..(X("\044 \084\050\058 ")..(b("\044 \076\058 ")..l("\046")))))))))end return z end


local EHP=_Tune.E_Horsepower/100
local ETQ=_Tune.E_Torque/100
local ETrans1=_Tune.E_Trans1/1000
local ETrans2=_Tune.E_Trans2/1000
local ELimit=_Tune.E_Redline/1000 

function elecHP(RPM)
	RPM=RPM/1000
	local retVal=1e-9
	if RPM<=ETrans1 then
		retVal=((((RPM/ETrans1)^_Tune.EH_FrontMult)/(1/EHP))*(RPM/ETrans1))+((((RPM/ETrans1)^(1/_Tune.EH_FrontMult))/(1/EHP))*(1-(RPM/ETrans1)))
	elseif ETrans1<RPM and RPM<ETrans2 then
		retVal=EHP
	elseif ETrans2<=RPM then
		retVal=EHP-(((RPM-ETrans2)/(ELimit-ETrans2))^_Tune.EH_EndMult)/(1/(EHP*(_Tune.EH_EndPercent/100)))
	else
		error( "\n\t [AC6C]: Drive initialization failed!"
			.."\n\t    An unknown error occured when initializing electric horsepower."
			.."\n\t    Please send a screenshot of this message to Avxnturador."
			.."\n\t    R: "..RPM..", T1: "..ETrans1", T2: "..ETrans2", L: "..ELimit".")
	end
	return retVal
end

function elecTQ(RPM)
	RPM=RPM/1000
	local retVal=1e-9
	if RPM<ETrans1 then
		retVal=ETQ
	elseif ETrans1<=RPM then
		retVal=ETQ-(((RPM-ETrans1)/(ELimit-ETrans1))^_Tune.ET_EndMult)/(1/(ETQ*(_Tune.ET_EndPercent/100)))
	else
		error( "\n\t [AC6C]: Drive initialization failed!"
			.."\n\t    An unknown error occured when initializing electric torque."
			.."\n\t    Please send a screenshot of this message to Avxnturador."
			.."\n\t    R: "..RPM..", T1: "..ETrans1", T2: "..ETrans2", L: "..ELimit".")
	end
	return retVal
end
