Nike.lua
-
Автор темы
- #1
Ну кароч хитлоги, похожие на хитлоги асидтеча
code_language.lua:
local Render_InitFont, Menu_Switch, Menu_SliderInt, Menu_ColorEdit, Color_new, Render_CalcTextSize, Render_Text, Vector2_new, EntityList_GetPlayer, Cheat_RegisterCallback, EngineClient_GetScreenSize = Render.InitFont, Menu.Switch, Menu.SliderInt, Menu.ColorEdit, Color.new, Render.CalcTextSize, Render.Text, Vector2.new, EntityList.GetPlayer, Cheat.RegisterCallback, EngineClient.GetScreenSize
local fonts = {
verdana = Render_InitFont("Verdana", 11, {"r"})
}
local screen = EngineClient_GetScreenSize() /2
local menu = {
timer = Menu_SliderInt("Sigma`s hitlogs", "Time to show", 5, 3, 15),
centered = Menu_Switch("Sigma`s hitlogs", "Centered", true),
neutral_text_color = Menu_ColorEdit("Sigma`s hitlogs", "Neutral color", Color_new(1.0, 1.0, 1.0, 1.0)),
hit_color = Menu_ColorEdit("Sigma`s hitlogs", "Hit color", Color_new(0.58, 0.78, 0.23, 1.0)),
resolver_color = Menu_ColorEdit("Sigma`s hitlogs", "Resolver color", Color_new(1.0, 0.0, 0.0, 1.0)),
spread_color = Menu_ColorEdit("Sigma`s hitlogs", "Spread color", Color_new(1.0, 0.78, 0.0, 1.0)),
occlusion_color = Menu_ColorEdit("Sigma`s hitlogs", "Occlusion color", Color_new(1.0, 0.78, 0.0, 1.0)),
prediction_color = Menu_ColorEdit("Sigma`s hitlogs", "Prediction color", Color_new(1.0, 0.50, 0.50, 1.0))
}
local CRender = {}
CRender.MultiColorString = function(table, x, y, size, font, centered, shadow)
outline = outline or false
centered = centered or false
shadow = shadow or false
if #table == 0 then return end
local text = ""
for i = 1, #table do
text = text..tostring(table[i][1])
end
local text_size = centered and -Render_CalcTextSize(text, size, font).x /2 or 0
for i = 1, #table do
if type(table[i][1]) ~= "string" then table[i][1] = tostring(table[i][1]) end
if shadow then
Render_Text(table[i][1], Vector2_new(x + text_size + 1, y + 1), Color_new(0,0,0,table[i][2].a), size, font)
end
Render_Text(table[i][1], Vector2_new(x + text_size, y), table[i][2], size, font)
text_size = text_size + Render_CalcTextSize(table[i][1], size, font).x
end
end
local Hitlogs = { Data = {} }
Hitlogs.Hitboxes = { [0] = "generic", [1] = "head", [2] = "chest", [3] = "stomach", [4] = "left arm", [5] = "right arm", [6] = "left leg", [7] = "right leg", [10] = "gear" }
Hitlogs.Reasons = { [1] = "unknown", [2] = "spread", [3] = "occlusion", [4] = "prediction error" }
Hitlogs.MissColors = { [1] = menu.resolver_color, [2] = menu.spread_color, [3] = menu.occlusion_color, [4] = menu.prediction_color }
Hitlogs.OnHit = function(shot)
if shot.reason ~= 0 then return end
local target = EntityList_GetPlayer(shot.target_index)
local health = target:GetProp("m_iHealth")
local remaining = health - shot.damage < 0 and 0 or health - shot.damage
local neutral_color = menu.neutral_text_color:GetColor()
local hit_color = menu.hit_color:GetColor()
table.insert(Hitlogs.Data, 1, {
{
{ "Hit ", neutral_color },
{ target:GetName().." ", hit_color },
{ "in the ", neutral_color },
{ Hitlogs.Hitboxes[shot.hitgroup].." ", hit_color },
{ "for ", neutral_color },
{ shot.damage.." ", hit_color },
{ "damage ", neutral_color },
{ "(", neutral_color },
{ remaining.." ", hit_color },
{ "health remaining)", neutral_color }
},
event_time = GlobalVars.curtime,
})
end
Hitlogs.OnMiss = function(shot)
if shot.reason == 0 then return end
local target = EntityList_GetPlayer(shot.target_index)
local neutral_color = menu.neutral_text_color:GetColor()
local miss = Hitlogs.MissColors[shot.reason]:GetColor()
table.insert(Hitlogs.Data, 1, {
{
{ "Missed ", neutral_color },
{ target:GetName(), miss },
{ "`s ", neutral_color },
{ Hitlogs.Hitboxes[shot.wanted_hitgroup].." ", miss },
{ "due to ", neutral_color },
{ Hitlogs.Reasons[shot.reason].." ", miss },
{ "(", neutral_color },
{ shot.hitchance, miss },
{ "% hitchance)", neutral_color }
},
event_time = GlobalVars.curtime,
})
end
Cheat_RegisterCallback("registered_shot", function(shot)
Hitlogs.OnHit(shot)
Hitlogs.OnMiss(shot)
end)
Hitlogs.OnRoundStart = function(event)
if event:GetName() == "round_start" then
Hitlogs.Data = {}
end
end
Cheat_RegisterCallback("events", function(event)
Hitlogs.OnRoundStart(event)
end)
Hitlogs.Draw = function()
local localplayer = EntityList.GetLocalPlayer()
if localplayer == nil then
Hitlogs.Data = {}
return
end
local time = menu.timer:Get()
local offset = 0
for i, this in pairs(Hitlogs.Data) do
CRender.MultiColorString(this[1], screen.x, screen.y + 160 + (13 * offset), 11, fonts.verdana, menu.centered:Get(), true)
if GlobalVars.curtime - this.event_time > time then
table.remove(Hitlogs.Data, i)
end
offset = offset + 1
end
end
Cheat_RegisterCallback("draw", function()
Hitlogs.Draw()
end)
Последнее редактирование: