-
Автор темы
- #1
''Bullet Tracer Thickness'' = 5 is the best visual effect
JavaScript:
var screen_size = Global.GetScreenSize();
var jsLoaded = false;
var rageTarget=0;
function duplicate(theObject) {
return JSON.parse(JSON.stringify(theObject));
}
function initializeMenuItems() {
UI.AddCheckbox("Show Bullet Tracer");
UI.AddSliderInt("Bullet Tracer Thickness", 2, 10);
UI.AddColorPicker("Bullet Tracer Color");
jsLoaded=true;
}
//Remade by Mixologist#6105
function setValue(key, value) {
UI.SetValue("Misc", "JAVASCRIPT", "Script items", key, value);
}
function getColor(key) {
return UI.GetColor("Misc", "JAVASCRIPT", "Script items", key);
}
initializeMenuItems();
var logging = false;
var frameCount = 0;
var frameLimit = 60;
function onCreateMove() {
if(!jsLoaded)return;
}
function onDraw() {
if (getFrameCount() >= frameLimit) {
resetFrameCount();
}
UIUpdate();
nextFrame();
}
function onUnload() {
jsLoaded = false;
}
function nextFrame() {
frameCount++;
}
function resetFrameCount() {
frameCount = 0;
}
function getFrameCount() {
return frameCount;
}
function getRandomInteger(min, max) {
return min + Math.ceil(Math.random() * (max - min));
}
Cheat.RegisterCallback("CreateMove", "onCreateMove");
Cheat.RegisterCallback("Draw", "onDraw");
Cheat.RegisterCallback("Unload", "onUnload");
var bullets = [];
function UIUpdate() {
if (UI.GetValue("Misc", "JAVASCRIPT", "Script items","Show Bullet Tracer")) drawBulletTracer();
}
function UI_onBulletImpact() {
if (!UI.GetValue("Misc", "JAVASCRIPT", "Script items","Show Bullet Tracer")) return;
player = Entity.GetEntityFromUserID(Event.GetInt("userid"));
if (Entity.GetLocalPlayer() !== player) return;
if (bullets.length > 20) bullets = [];
eyePos = Entity.GetEyePosition(Entity.GetLocalPlayer());
vector = [Event.GetFloat("x") - eyePos[0], Event.GetFloat("y") - eyePos[1], Event.GetFloat("z") - eyePos[2]];
eyePos[0] += vector[0] * 0.01;
eyePos[1] += vector[1] * 0.01;
eyePos[2] += vector[2] * 0.01;
bullets.push({
"impact": [Event.GetFloat("x"), Event.GetFloat("y"), Event.GetFloat("z")],
"origin": eyePos,
"time": Globals.Curtime()
});
}
function drawBulletTracer() {
if (bullets.length < 1) return;
for (i = 0; i < bullets.length; i++) {
if (bullets[i] != undefined) {
if (bullets[i]["time"] + 2 < Globals.Curtime()) {
delete bullets[i];
} else {
impact = Render.WorldToScreen(bullets[i]["impact"]);
origin = Render.WorldToScreen(bullets[i]["origin"]);
if (origin != undefined && impact != undefined) {
if (origin[2] == 0 && !UI.IsHotkeyActive("Visual", "WORLD", "View", "Thirdperson")) {
vector = [bullets[i]["impact"][0] - bullets[i]["origin"][0], bullets[i]["impact"][1] - bullets[i]["origin"][1], bullets[i]["impact"][2] - bullets[i]["origin"][2]];
newOrigin = duplicate(bullets[i]["origin"]);
length = getDistance(bullets[i]["impact"], newOrigin) - getDistance(bullets[i]["impact"], Entity.GetEyePosition(Entity.GetLocalPlayer()));
newOrigin[0] += vector[0] * (length / getDistance(bullets[i]["impact"], newOrigin) + 0.05);
newOrigin[1] += vector[1] * (length / getDistance(bullets[i]["impact"], newOrigin) + 0.05);
newOrigin[2] += vector[2] * (length / getDistance(bullets[i]["impact"], newOrigin) + 0.05);
origin = Render.WorldToScreen(newOrigin);
}
if (impact[2] != 0 && origin[1] < screen_size[1] && origin[0] < screen_size[0] && origin[0] > 0) {
Render.Line(impact[0], impact[1], origin[0], origin[1], getColor("Bullet Tracer Color"));
step = Math.floor(getColor("Bullet Tracer Color")[3] / UI.GetValue("Misc", "JAVASCRIPT", "Script items","Bullet Tracer Thickness"));
for (x = 1; x < UI.GetValue("Misc", "JAVASCRIPT", "Script items","Bullet Tracer Thickness"); x++) {
Render.Line(impact[0] + (x - 1), impact[1], origin[0] + x, origin[1], [getColor("Bullet Tracer Color")[0], getColor("Bullet Tracer Color")[1], getColor("Bullet Tracer Color")[2], getColor("Bullet Tracer Color")[3] - (x * step)]);
Render.Line(impact[0], impact[1] + (x - 1), origin[0], origin[1] + x, [getColor("Bullet Tracer Color")[0], getColor("Bullet Tracer Color")[1], getColor("Bullet Tracer Color")[2], getColor("Bullet Tracer Color")[3] - (x * step)]);
Render.Line(impact[0] - (x - 1), impact[1], origin[0] - x, origin[1], [getColor("Bullet Tracer Color")[0], getColor("Bullet Tracer Color")[1], getColor("Bullet Tracer Color")[2], getColor("Bullet Tracer Color")[3] - (x * step)]);
Render.Line(impact[0], impact[1] - (x - 1), origin[0], origin[1] - x, [getColor("Bullet Tracer Color")[0], getColor("Bullet Tracer Color")[1], getColor("Bullet Tracer Color")[2], getColor("Bullet Tracer Color")[3] - (x * step)]);
}
}
}
}
}
}
}
function getDistance(A, B) {
return Math.sqrt(Math.pow(A[0] - B[0], 2) + Math.pow(A[1] - B[1], 2) + Math.pow(A[2] - B[2], 2));
}
Cheat.RegisterCallback('bullet_impact', 'UI_onBulletImpact');
Последнее редактирование: