Divergent/mods/1st Person Visible Body/gamedata/scripts/_u.script

467 lines
12 KiB
Plaintext
Raw Permalink Normal View History

2024-03-17 20:18:03 -04:00
--[[ ----------------------------------------------------------------------------------------------
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CS 1.5.10, CoP 1.6.02
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 2013 <20> Shoker Weapon Mod
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> : Shoker, <...>
Shoker Weapon Mod 2.1 port, modified by Wang_Laoshi (Ethereal) to work with Anomaly mod. Thanks a lot to the original creators of this mod - Shoker, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> and SWM Team in general.
--]] ----------------------------------------------------------------------------------------------
--[[
TODO:
* <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> ltx() <20><> ini-<2D><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> system_ini() <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ini, <20><> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>
--]]
--************************************************************--
--***********************[<5B><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>]***********************--
--************************************************************--
local _SN = script_name()
--**************************************************************--
--********************[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>]********************--
--**************************************************************--
--\\ <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD>" (Roll <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> malandrinus <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function get_all_direction(dir)
--* "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
local dir_right = vector()
dir_right:crossproduct(dir, vector():set(0,1,0))
dir_right = dir_right:normalize()
--* "<22><><EFBFBD><EFBFBD><EFBFBD>"
local dir_up = vector()
dir_up:crossproduct(dir_right, dir)
dir_up = dir_up:normalize()
return dir_right:invert(), dir_up
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
--\\ <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (malandrinus)
function point_to_hud(point)
local dev = device()
local scr_w = dev.width
local scr_h = dev.height
local fov2 = (dev.fov/2) * (math.pi/180)
local scr_dist = 0.5 * scr_h / math.tan(fov2)
local ppp = vector():sub(point, dev.cam_pos)
local dp = dev.cam_dir:dotproduct(ppp)
local x = 512 + dev.cam_right:dotproduct(ppp) * scr_dist / dp * (1024/scr_w)
local y = 384 - dev.cam_top:dotproduct(ppp) * scr_dist / dp * (768/scr_h)
return x, y
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> X,Y <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function angle_to_direction(oangle)
local yaw = oangle.y
local pitch = oangle.x
return vector():setHP(yaw,pitch):normalize()
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> float-<2D><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function frandom(n1, n2)
n1 = n1 * 10
n2 = n2 * 10
return (math.random(n1, n2) / 10)
end
local ltxBuffer = {} --> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- sec - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- line - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- *mode - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ("str", "tbl1", "bol", "num", "numf")
-- *ini_file - ini-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> system.ltx <20> <20><><EFBFBD><EFBFBD><EFBFBD>. <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<5C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
function ltx(sec, line, mode, ini_file)
if sec == nil then
_abort(_SN, "ltx", "sec (%s)(%s)", tostring(line), tostring(mode))
end
if not ltxBuffer[sec] then
ltxBuffer[sec] = {}
end
local result = ltxBuffer[sec][line]
if result ~= nil then
--* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if type(result) == "userdata" then
return utils.vector_copy_by_val(result)
end
return result
end --> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
local ini = ini_file or system_ini()
if ltxExist(sec, line, ini) then
if mode==nil or mode=="numf" then --> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ltxBuffer[sec][line] = ini:r_float(sec, line)
return ltxBuffer[sec][line]
end
if mode=="bol" then --> true\false
ltxBuffer[sec][line] = ini:r_bool(sec, line)
return ltxBuffer[sec][line]
end
if mode=="num" then --> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
ltxBuffer[sec][line] = ini:r_u32(sec, line)
return ltxBuffer[sec][line]
end
if mode=="str" then --> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ltxBuffer[sec][line] = ini:r_string(sec, line)
return ltxBuffer[sec][line]
end
if mode=="vec" then --> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
local vec = ini:r_vector(sec, line)
ltxBuffer[sec][line] = vec
--return ltxBuffer[sec][line] --> <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
return utils.vector_copy_by_val(ltxBuffer[sec][line])
end
if mode=="tbl1" then --> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (1 = ..., 2 = ....)
local temp = ini:r_string(sec, line)
ltxBuffer[sec][line] = string_expl(temp, ",")
return ltxBuffer[sec][line]
end
end
-- mDbg(_SN, "ltx - no section: "..sec.." || "..line)
return nil
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function ltxBufferW(sec, line, value)
if not ltxBuffer[sec] then
ltxBuffer[sec] = {}
end
ltxBuffer[sec][line] = value
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- sec - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function ltxItem(sec)
local name = ltx(sec, "inv_name", "str") or ""
local descr = ltx(sec, "description", "str") or ""
return xml(name), xml(descr)
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- sec - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- *line - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- *ini_file - ini-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> system.ltx <20> <20><><EFBFBD><EFBFBD><EFBFBD>. <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function ltxExist(sec, line, ini_file)
local ini = ini_file or system_ini()
if sec == nil then _abort(_SN, "ltxExist", "sec") end
if not ini:section_exist(sec) then return false end
if line and not ini:line_exist(sec, line) then return false end
printf("SWMtrue")
return true
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <text> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> xml-<2D><><EFBFBD><EFBFBD><EFBFBD>
-- xml_id - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function xml(xml_id)
return game.translate_string(xml_id)
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> custom data
--[[
local value = 123
local cd = {}
cd["test"] = {}
cd["test"]["string"] = ""
cd["test"]["line"] = value
cd["test"]["simple_table"] = {2,4,6,8}
cd["test"]["extended_table"] = {val1 = 1, val2 = 2, val3 = 3}
[test]
string
line = 123
simple_table = 2468
extended_table = val1, 1, val2, 2, val3, 3
]]
function tocdata(tTbl)
local result = ""
for sec, tData in pairs(tTbl) do
result = result.."\n["..sec.."]\n"
if type(tData) ~= "table" then
_abort(_SN, "tocdata", "tData is not table! result = %s, tData = %s", result, tostring(tData))
else
for line, t_Param in pairs(tData) do
if t_Param == "" then
result = result..tostring(line).."\n"
else
result = result..tostring(line).." = "
if type(t_Param) == "table" then
if table_size(t_Param) > 0 and #t_Param > 0 then
--* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
for _,p1 in pairs(t_Param) do
local first = true
if first then
result = result..tostring(p1)
first = false
else
result = result..", "..tostring(p1)
end
end
else
--* <20><><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
local first = true
for p1,p2 in pairs(t_Param) do
if first then
result = result..tostring(p1)..", "..tostring(p2)
first = false
else
result = result..", "..tostring(p1)..", "..tostring(p2)
end
end
end
result = result.."\n"
else
result = result..tostring(t_Param).."\n"
end
end
end
end
end
return result
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function collect_sections(ini, sec)
local r = {}
if ini:section_exist(sec) then
local n = ini:line_count(sec)
if n > 0 then
for i = 0,n-1 do
local res,id,val = ini:r_line(sec,i,"","")
if r[id] == nil then
r[id] = val
end
end
end
end
return r
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD>
function _abort(script_name, function_name, error_string, ...)
if script_name == nil then
script_name = "<nil>"
end
if function_name == nil then
function_name = "<nil>"
end
abort("%s.%s - "..error_string, script_name, function_name, ...)
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD>
function log(text)
if _console == nil or (_console.GetVal("dbg.log") == true) then
get_console():execute("load ~~ " .. tostring(text))
end
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
function table_size(tTbl)
local count = 0
for _,_ in pairs(tTbl) do
count = count + 1
end
return count
end
--! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #) <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
function string_expl(sStr, sDiv, Mode, bNoClear)
sStr = tostring(sStr)
if not (sStr ~= "nil" and sStr ~= '') then return {} end --> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
local tRet = {}
local sPattern = '[%w%_]+' --> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
if type(sDiv) == "string" then --> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>
if bNoClear then --> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
sPattern = '([^'..sDiv..']+)'
else --> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
sPattern = '%s*([^'..sDiv..']+)%s*'
end
end
--* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if Mode == nil then --> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for sValue in sStr:gmatch(sPattern) do
table.insert(tRet, sValue)
end
else
local sTypeMode = type(Mode)
if sTypeMode == "boolean" then --> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>] = true <20><><EFBFBD> false'
for sValue in sStr:gmatch(sPattern) do
tRet[sValue] = Mode
end
elseif sTypeMode == "number" then --> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '[idx] = <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
for sValue in sStr:gmatch(sPattern) do
tRet[#tRet+1] = tonumber(sValue) or sValue
end
end
end
return tRet --> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
end
--* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> cam_dir:getH()
-- <20><>, <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>_<EFBFBD>
function calc_Y(new, old)
local wL = 0
local wR = 0
if new < old then
wR = old - new
if new < 0 then
wL = math.abs(-1.6 - new) + (4.8 - old)
else
wL = new + 1.6 + (4.8 - old)
end
else
wL = new - old
if old < 0 then
wR = (4.8 - new) + math.abs(-1.6 - old)
else
wR = (4.8 - new) + math.abs(-1.6) + old
end
end
if wL < wR then
return wL
end
if wL > wR then
return -wR
end
return 0
end
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> x,z,y (P,B,H)
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Wild Magic 5
function extract_euler_xzy(m)
if m.i.y < 1 then
if m.i.y > -1 then
local az = math.asin(-m.i.y)
local ax = math.atan2(m.k.y, m.j.y)
local ay = math.atan2(m.i.z, m.i.x)
return ax, az, ay
else
local az = math.pi / 2
local ax = -math.atan2(-m.k.x, m.k.z)
local ay = 0
return ax, az, ay
end
else
local az = -math.pi / 2
local ax = math.atan2(-m.k.x, m.k.z)
local ay = 0
return ax, az, ay
end
end
function extract_direction(ph_element)
local m = ph_element:global_transform()
local p,b,h = extract_euler_xzy(m)
return vector():setHP(h, p)
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> ID\Server OBJ
function getMapName(id_or_sobj)
local sobj
if type(id_or_sobj) == "number" then
sobj = alife():object(id_or_sobj)
else
sobj = id_or_sobj
end
if sobj then
local lvert = game_graph():vertex(sobj.m_game_vertex_id)
local lid = lvert:level_id()
if lid ~= nil then
return alife():level_name(lid)
end
end
end
--\\ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD>) <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>)
local rang_num_to_name = {
[0] = "st_rang_zero",
[1] = "st_rang_novice",
[2] = "st_rang_experienced",
[3] = "st_rang_experienced",
[4] = "st_rang_veteran",
[5] = "st_rang_master",
}
function rang(obj)
local rank = 0
local obj_rank = obj:rank()
if obj_rank >=0 and obj_rank <=25 then --> novice
rank = 1
end
if obj_rank >=26 and obj_rank <=30 then --> ext 1
rank = 2
end
if obj_rank >=31 and obj_rank <=40 then --> ext 2
rank = 3
end
if obj_rank >=41 and obj_rank <=50 then --> veteran
rank = 4
end
if obj_rank >=51 then --> master
rank = 5
end
--[[ CS 1.5.10
if obj_rank >= 0 and obj_rank <= 300 then
rank = 1 -- Novice
end
if obj_rank > 300 and obj_rank <= 450 then
rank = 2 -- Extnd. 1
end
if obj_rank > 450 and obj_rank <= 600 then
rank = 3 -- Extnd. 2
end
if obj_rank > 600 and obj_rank < 900 then
rank = 4 -- Veteran
end
if obj_rank >= 900 then
rank = 5 -- Master
end
]]
return rank, obj_rank, rang_num_to_name[rank]
end