-
Автор темы
- #1
JavaScript:
var y = 0;
function line(p1, p2) {
Render.Line(p1[0], p1[1], p2[0] , p2[1]-y, [255, 255, 255, 200 - Math.min(y*2, 1000)])
Render.Line(p1[0], p1[1]+1, p2[0], p2[1]+1-y, [255, 255, 255, 200 - Math.min(y*2, 200)])
Render.Line(p1[0], p1[1]+2, p2[0], p2[1]+2-y, [255, 255, 255, 200 - Math.min(y*2, 200)])
Render.Line(p1[0], p1[1]+2.4, p2[0], p2[1]+2.4-y, [255, 255, 255, 200 - Math.min(y*2, 200)])
Render.Line(p1[0], p1[1]-y, p2[0], p2[1]+y, [255, 255, 255, 200 - Math.min(y*2, 200)])
}
var hp = Entity.GetProp(Entity.GetLocalPlayer(), "CBasePlayer", "m_iHealth");
function on_draw() {
if (!World.GetServerString())
return;
var t = Globals.Frametime() * (10 + Math.abs(Entity.GetProp(Entity.GetLocalPlayer(), "CBasePlayer", "m_iHealth") - hp) * 1.3);
if (hp > Entity.GetProp(Entity.GetLocalPlayer(), "CBasePlayer", "m_iHealth"))
hp = Math.max(hp - t, Entity.GetProp(Entity.GetLocalPlayer(), "CBasePlayer", "m_iHealth"));
else if (hp < Entity.GetProp(Entity.GetLocalPlayer(), "CBasePlayer", "m_iHealth"))
hp = Math.min(hp + t, Entity.GetProp(Entity.GetLocalPlayer(), "CBasePlayer", "m_iHealth"));;
if (!Entity.IsAlive(Entity.GetLocalPlayer())) {
y = Math.min(y+t*2, 130);
}
else {
y = Math.max(y-t*2, 0);
}
var texture = Render.AddTexture("ot/scripts/hp/hp.png")
Render.TexturedRect(0, 0 - y, 722, 126, texture)
if (hp == 100) {
Render.FilledCircle(568, 73, 2, [180, 190, 200,255])
}
if (hp > 90) {
var o_x = (712 - 666) * (1 - ((hp - 90) / 10))
var o_y = (38 - 30) * (1 - ((hp - 90) / 10))
Render.FilledCircle(534, 64-y, 2, [255, 255, 255,255])
Render.FilledCircle(325, 68-y, 2, [255, 255, 255,255])
Render.FilledCircle(298, 60-y, 2, [255, 255, 255,255])
Render.FilledCircle(200, 65-y, 2, [255, 255, 255,255])
Render.FilledCircle(145, 77-y, 2, [255, 255, 255,255])
Render.FilledCircle(124, 68-y, 2, [255, 255, 255,255])
Render.FilledCircle(112, 78-y, 2, [255, 255, 255,255])
line([534, 64], [569 - o_x, 73 - o_y])
line([325, 68], [535, 64])
line([298, 60], [325, 68])
line([202, 65], [299, 60])
line([145, 77], [201, 65])
line([123, 67], [146, 77])
line([111, 78], [123, 68])
}
else if (hp > 50) {
var o_x = (666 - 394) * (1 - (hp - 50) / 40)
var o_y = (47 - 52) * (1 - (hp - 50) / 40)
Render.FilledCircle(325, 68-y, 2, [255, 255, 255,255])
Render.FilledCircle(298, 60-y, 2, [255, 255, 255,255])
Render.FilledCircle(200, 65-y, 2, [255, 255, 255,255])
Render.FilledCircle(145, 77-y, 2, [255, 255, 255,255])
Render.FilledCircle(124, 68-y, 2, [255, 255, 255,255])
Render.FilledCircle(112, 78-y, 2, [255, 255, 255,255])
line([325, 68], [535 - o_x, 64 - o_y])
line([298, 60], [325, 68])
line([202, 65], [299, 60])
line([145, 77], [201, 65])
line([123, 67], [146, 77])
line([111, 78], [123, 68])
}
else if (hp > 40) {
var o_x = (394 - 358) * ((hp - 50) / -10)
var o_y = (52 - 41) * ((hp - 50) / -10)
Render.FilledCircle(298, 60-y, 2, [255, 255, 255,255])
Render.FilledCircle(200, 65-y, 2, [255, 255, 255,255])
Render.FilledCircle(145, 77-y, 2, [255, 255, 255,255])
Render.FilledCircle(124, 68-y, 2, [255, 255, 255,255])
Render.FilledCircle(112, 78-y, 2, [255, 255, 255,255])
line([298, 60], [325 - o_x, 68 - o_y])
line([202, 65], [299, 60])
line([145, 77], [201, 65])
line([123, 67], [146, 77])
line([111, 78], [123, 68])
}
else if (hp > 20) {
var o_x = (358 - 232) * ((hp - 40) / -20)
var o_y = (41 - 48) * ((hp - 40) / -20)
Render.FilledCircle(200, 65-y, 2, [255, 255, 255,255])
Render.FilledCircle(145, 77-y, 2, [255, 255, 255,255])
Render.FilledCircle(124, 68-y, 2, [255, 255, 255,255])
Render.FilledCircle(112, 78-y, 2, [255, 255, 255,255])
line([202, 65], [298 - o_x, 60 - o_y])
line([145, 77], [201, 65])
line([123, 67], [146, 77])
line([111, 78], [123, 68])
}
else if (hp > 10) {
var o_x = (232 - 160) * ((hp - 20) / -10)
var o_y = (48 - 64) * ((hp - 20) / -10)
Render.FilledCircle(145, 77-y, 2, [255, 255, 255,255])
Render.FilledCircle(124, 68-y, 2, [255, 255, 255,255])
Render.FilledCircle(112, 78-y, 2, [255, 255, 255,255])
line([145, 77], [202 - o_x, 65 - o_y])
line([123, 67], [146, 77])
line([111, 78], [123, 68])
}
else if (hp > 5) {
var o_x = (160 - 131) * ((hp - 10) / -5)
var o_y = (64 - 51) * ((hp - 10) / -5)
Render.FilledCircle(124, 68-y, 2, [255, 255, 255,255])
Render.FilledCircle(112, 78-y, 2, [255, 255, 255,255])
line([123, 67], [160 - o_x, 64 - o_y])
line([111, 78], [123, 68])
}
else {
var o_x = (131 - 116) * ((hp - 5) / -5)
var o_y = (51 - 65) * ((hp - 5) / -5)
Render.FilledCircle(112, 78-y, 2, [255, 255, 255,255])
lline([111, 78], [131 - o_x, 51 - o_y])
}
}
Cheat.RegisterCallback('Draw', 'on_draw')