Skip to content

Commit

Permalink
Move mark switch to github
Browse files Browse the repository at this point in the history
  • Loading branch information
andtheherois committed Aug 29, 2024
1 parent 8aa6c55 commit e3f5c22
Show file tree
Hide file tree
Showing 64 changed files with 414 additions and 0 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[markswitch_colors]
reflex_red = 1, 0.2, 0.2, 0.7
reflex_green = 0, 1, 0, 0.7
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
; Sights

![ekp8_02]
ms_count = 4

![ekp8_18]
ms_count = 4

![kp_sr2]
ms_count = 4

![okp]
ms_count = 2

![0kp2]
ms_count = 2

![okep77]
ms_count = 2

; Integrated

![wpn_sr2_veresk_sr2_upkit]
ms_count = 4

![wpn_ppsh_bas_uptacppsh]
ms_count = 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
; Sights

![ac10632]
ms_count = 8

![kobra]
ms_count = 4

![ekp8_02]
ms_count = 4

![ekp8_18]
ms_count = 4

![kp_sr2]
ms_count = 4

![okp]
ms_count = 6

![0kp2]
ms_count = 6

![okep77]
ms_count = 6

![eot]
ms_count = 6

![e0t2]
ms_count = 6

![rakurs]
ms_count = 2

![1p76]
ms_count = 2

![rmr]
ms_count = 2

![deltapoint]
ms_count = 2

![d0cter]
ms_count = 2

![aimpoint]
ms_count = 2

![aim_low]
ms_count = 2

![point_aimpro]
ms_count = 2

![aimpoint_pro]
ms_count = 2

![compm4s]
ms_count = 2

![mepro]
ms_count = 2

![c-more]
ms_count = 2

![kemper]
ms_count = 2

![lco1]
ms_count = 2

![pk6]
ms_count = 3

![p1x42]
ms_count = 3

![romeo4]
ms_count = 4

![romeo8]
ms_count = 1

![he510]
ms_count = 2

; Integrated

![wpn_toz34_bull]
ms_count = 4

![wpn_ak74u_snag]
ms_count = 4

![wpn_pkm_zulus]
ms_count = 4

![wpn_sr2_veresk_sr2_upkit]
ms_count = 4

![wpn_ppsh_bas_uptacppsh]
ms_count = 4

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[sights]
pk6 = 3
kp_sr2 = 4

[integrated]
wpn_toz34_bull = 4
wpn_ak74u_snag = 4
wpn_pkm_zulus = 4
wpn_sr2_veresk_sr2_upkit = 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="windows-1251"?>
<string_table>

<string id="ui_mcm_menu_mark_switch">
<text>Mark Switch</text>
</string>

<string id="ui_mcm_mark_switch_title">
<text>Mark switch</text>
</string>

<string id="ui_mcm_mark_switch_keybind">
<text>Reflex sight mark switch</text>
</string>

</string_table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="windows-1251"?>
<string_table>

<string id="ui_mcm_menu_mark_switch">
<text>Mark Switch</text>
</string>

<string id="ui_mcm_mark_switch_title">
<text>Ïåðåêëþ÷åíèå ìàðêè</text>
</string>

<string id="ui_mcm_mark_switch_keybind">
<text>Ïåðåêëþ÷åíèå ìàðêè êîëëèìàòîðíîãî ïðèöåëà</text>
</string>

</string_table>
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
--[[
=====================================================================
Addon : Mark Switch
Link : https://www.moddb.com/mods/stalker-anomaly/addons/mark-switch
Author : party_50
Date : 10.02.2024
Last Edit : 13.03.2024
=====================================================================
--]]


local KEYBIND
local SOUND

local current_marks = {}
local last_weapon_id


function init()
SOUND = sound_object('interface\\mark_adjust')
end

function on_option_change()
KEYBIND = z_mark_switch_mcm.get_config("keybind")
end

function get_sight_section(wpn_section)
local parent = ini_sys:r_string_ex(wpn_section, "parent_section") or wpn_section
if #parent == #wpn_section then
return wpn_section
end

return wpn_section:sub(#parent + 2)
end

function get_mark_count(sight)
return ini_sys:r_float_ex(sight, "ms_count") or 1
end

function get_mark_color(sight, i)
local colors = parse_list(ini_sys, sight, "ms_colors")
if not colors or #colors == 0 then
return "0, 0, 0, 0"
end

if i >= #colors then
i = #colors - 1
end

return ini_sys:r_string_ex("markswitch_colors", colors[i + 1])
end

function update_shader(wpn_id, sight)
get_console():execute("markswitch_current " .. tostring(current_marks[wpn_id] or 0))
get_console():execute("markswitch_count " .. tostring(get_mark_count(sight)))
get_console():execute("markswitch_color " .. get_mark_color(sight, current_marks[wpn_id] or 0))
end

function apply_next_mark(wpn_id, sight)
SOUND:play(db.actor, 0, sound_object.s2d)
game.play_hud_anm("script\\mark_adjust.anm", 2, 2, 1, false, false)

local mark = current_marks[wpn_id] or 0
mark = (mark + 1) % get_mark_count(sight)
current_marks[wpn_id] = mark

update_shader(wpn_id, sight)
end

function on_key_release(key)
if key == KEYBIND then
if not (db.actor and db.actor:alive()) then
return
end

local wpn = db.actor:active_item()
if not wpn then
return
end

local sight = get_sight_section(wpn:section())
if get_mark_count(sight) < 2 then
return
end

apply_next_mark(wpn:id(), sight)
end
end

function actor_on_update()
if not (db.actor and db.actor:alive()) then
return
end

local wpn = db.actor:active_item()
if not wpn then
return
end

if not last_weapon_id or last_weapon_id ~= wpn:id() then
last_weapon_id = wpn:id()
local sight = get_sight_section(wpn:section())
update_shader(wpn:id(), sight)
end
end

function server_entity_on_unregister(obj)
if current_marks[obj.id] then
current_marks[obj.id] = nil
end
end

function save_state(m_data)
m_data.mark_switch_current_marks = current_marks
end

function load_state(m_data)
current_marks = type(m_data.mark_switch_current_marks) == "table" and m_data.mark_switch_current_marks or {}
end

function on_game_start()
init()
on_option_change()
RegisterScriptCallback("on_option_change", on_option_change)
RegisterScriptCallback("on_key_release", on_key_release)
RegisterScriptCallback("actor_on_update", actor_on_update)
RegisterScriptCallback("server_entity_on_unregister", server_entity_on_unregister)
RegisterScriptCallback("save_state", save_state)
RegisterScriptCallback("load_state", load_state)
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- If you don't use MCM, change your defaults from here
local defaults = {
["keybind"] = DIK_keys.DIK_EQUALS
}

function get_config(key)
if ui_mcm then
return ui_mcm.get("mark_switch/" .. key)
else
return defaults[key]
end
end

function on_mcm_load()
op = {
id = "mark_switch",
sh = true,
gr = {
{id = "title", type = "slide", link = "ui_options_slider_player", text = "ui_mcm_mark_switch_title", size = {512, 50}, spacing = 20},
{id = "keybind", type = "key_bind", val = 2, def = DIK_keys.DIK_EQUALS},
}
}
return op
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#define MARK_ADJUST 1

uniform float4 markswitch_current;
uniform float4 markswitch_count;
uniform float4 markswitch_color;

int mark_sides()
{
int sides = 1;
while (sides * sides < int(markswitch_count.x))
{
sides += 1;
}

return sides;
}

float2 mark_adjust(float2 pos)
{
int sides = mark_sides();

float d_x = int(markswitch_current.x) % sides;
float d_y = int(markswitch_current.x) / sides;

float p_x = clamp(d_x + pos.x, d_x, d_x + 1) / sides;
float p_y = clamp(d_y + pos.y, d_y, d_y + 1) / sides;

return float2(p_x, p_y);
}

float current_lum()
{
float lum_min = 0.85;
float lum_max = 3;
float lum = s_tonemap.Load(int3(0, 0, 0)).x;
return clamp(1 - (lum - lum_min) / (lum_max - lum_min), 0, 1);
}

float4 lum_adjust(float4 color)
{
if (markswitch_color.a)
color = float4(markswitch_color.r, markswitch_color.g, markswitch_color.b, markswitch_color.a * (color.r + (1 - current_lum()) * color.g));
return color;
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function normal (shader, t_base, t_second, t_detail)
shader:begin ("model_def_lplanes","models_lfo_light_dot_weapons")
: fog (true)
: zb (true,false)
: blend (true,blend.srcalpha,blend.invsrcalpha)
: aref (true,0)
: sorting (2,true)
: distort (true)
shader:dx10texture ("s_base", t_base)
shader:dx10texture ("s_tonemap", "$user$tonemap")
end
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit e3f5c22

Please sign in to comment.