/
xr_extensions.script
709 lines (685 loc) · 21.4 KB
/
xr_extensions.script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
-- -*- mode: lua; encoding: windows-1251 -*-
--local tmr = profile_timer()
--tmr:start()
RvP() -- init Lua extension
_G.sys_ini = system_ini()
_G.is_16_9_mode = function()
return device().width/device().height > (1024/768 + 0.01)
end
_G.kScreen = math.min( (device().height/device().width/0.75), 1 )
set_static_rescale_factor( _G.kScreen )
game_options.load_game_options()
-- X-ray extensions callbacks
-- CActor
callback.on_key_press = 123
callback.on_key_release = 124
callback.on_key_hold = 125
callback.on_mouse_wheel = 126
callback.on_mouse_move = 127
callback.on_anomaly_hit = 128
callback.on_drop_inv_item = 129
callback.on_belt = 130
callback.on_ruck = 131
callback.on_slot = 132
callback.on_select_item = 133
callback.on_create_cell_item = 136
callback.on_attach_vehicle = 137
callback.on_vehicle_exit = 138
callback.on_detach_vehicle = 139
callback.after_save = 140
callback.on_focus_item = 141
callback.on_focus_lost_item = 142
callback.on_grouping_item = 143
callback.on_mob_hit_to_actor = 144
callback.on_change_goodwill = 145
callback.on_before_use_item = 156
callback.on_animation_end = 157
callback.pda_contact = 180
-- CTorch
callback.on_switch_torch = 134
-- CAIStalker
callback.on_set_dest_vertex = 135
-- CInventoryBox
callback.on_inv_box_put_item = 151
-- CEntityAlive
callback.entity_alive_before_hit = 152
-- CWeapon
callback.update_addons_visibility = 154
callback.update_hud_addons_visibility = 155
-- Некоторые недостающие key_bindings
key_bindings.kENGINE = 15
key_bindings.kACTIVE_JOBS = 53
key_bindings.kMAP = 54
key_bindings.kCONTACTS = 55
key_bindings.kEXT_1 = 56
key_bindings.kUSE_BANDAGE = 73
key_bindings.kUSE_MEDKIT = 74
key_bindings.kQUICK_SAVE = 75
key_bindings.kQUICK_LOAD = 76
key_bindings.DUMMY = 78
-- Некоторые недостающие DIK_keys
DIK_keys.DUMMY = 0
DIK_keys.DIK_LMOUSE = 337
DIK_keys.DIK_RMOUSE = 338
DIK_keys.DIK_WMOUSE = 339
_G.inventory_slots = {
-- active_slot возвращает 4294967296, а в activate_slot передавать надо 4294967295. Сталкир...
NO_ACTIVE_SET = 4294967295,
NO_ACTIVE_GET = 4294967296,
KNIFE = 0,
PISTOL = 1,
RIFLE = 2,
GRENADE = 3,
APPARATUS = 4,
BOLT = 5,
OUTFIT = 6,
PDA = 7,
DETECTOR = 8,
TORCH = 9,
ARTEFACT = 10,
TOTAL = 11
}
-- Движковая таблица EIIFlags для CInventoryItem
_G.ii_flags = {
drop_manual = 1, -- Fdrop
can_take = 2, -- FCanTake
can_trade = 4, -- FCanTrade
belt = 8, -- Fbelt
ruck = 16, -- Fruck
ruck_default = 32, -- FRuckDefault
using_condition = 64, -- FUsingCondition
allow_sprint = 128, -- FAllowSprint
useful_for_npc = 256, -- Fuseful_for_NPC
in_interpolation = 512, -- FInInterpolation
in_interpolate = 1024, -- FInInterpolate
is_quest_item = 2048, -- FIsQuestItem
-- extra flags added in X-Ray Extensions
always_tradable = 4096,
always_untradable = 8192,
ungroupable = 16384,
manual_highlighting = 32768,
}
_G.addon_flags = {
scope = 1,
grenade_launcher = 2,
silencer = 4
}
-- extension of namespaces Lua
--// string
-- обрезаем пробелы по краям строки
if string.trim==nil then
_G.trim = function (s)
return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end
else
_G.trim = string.trim
end
-- разбивка строки по символу
string.explode = function ( str, div, clear )
local ret = {}
for s in string.gmatch( str, "([^"..div.."]+)" ) do
ret[ #ret+1 ] = ( clear and trim( s ) or s )
end
return ret
end
-- 'string.lower/upper' с поддержкой кириллицы.
local lower = string.lower
string.lower = function ( str )
return lower( str:gsub( "([А-Я])",
function( s ) return string.char( s:byte()+32 ) end ):gsub( "Ё", "ё" ) )
end
local upper = string.upper
string.upper = function ( str )
return upper( str:gsub( "([а-я])",
function( s ) return string.char( s:byte()-32 ) end ):gsub( "ё", "Ё" ) )
end
-- очистка строки от недопустимых для имён файлов символов (используется при работе с FS)
string.clear = function ( str )
return str:gsub( "%p", function( s ) return s:match( "[%.%-_]*" ) end )
end
--// math
-- выравнивание значения n в пределы от min до max
math.clamp = function( n, min, max )
if min > max then
min, max = max, min
end
return ( n > max and max ) or ( n < min and min ) or n
end
-- округление числа
math.round = function ( n )
return math.floor(n + 0.5)
end
--// table
-- получаем размер таблицы (количество связок [ключ] = значение)
if table.size == nil then
table.size = function ( t )
local n = 0
for _ in pairs( t ) do n = n + 1 end
return n
end
end
-- копируем все данные из таблицы src в таблицу tbl
table.copy = function ( tbl, src )
for k,v in pairs( src ) do
if type( v ) == 'table' then
tbl[ k ] = table.copy( {}, v )
else
tbl[ k ] = v
end
end
return tbl
end
-- поиск значения в таблице
table.find = function( tbl, val )
local tp = type(val)
for k,v in pairs(tbl) do
if type(v)==tp and v==val then return true end
end
return false
end
-- функции для подсчета чего-либо в виде: [ключ] = количество
-- добавить
table.add = function( tbl, key, v )
local n = tbl[key] or 0
tbl[key] = n + (v or 1)
end
-- отнять
table.sub = function( tbl, key, v )
local n = tbl[key] or 0
if n <= (v or 1) then
tbl[key] = nil
else
tbl[key] = n - (v or 1)
end
end
-- получение рандомного значения из массива
table.random = function ( tbl )
if not next(tbl) then return nil end
return tbl[ math.random(#tbl) ]
end
-- преобразование массива в хэш: [значение] = true
table.tohash = function ( tbl )
local ret = {}
for i, v in ipairs( tbl ) do
ret[ v ] = true
end
return ret
end
-- расширенная распечатка таблицы в лог
table.print = function( tbl, subs )
subs = subs or ""
local s
for k,v in pairs(tbl) do
s = (type(k)=="userdata" and "userdata") or tostring(k)
if type(v) == "table" then
log1(subs..s..":table")
table.print(v, subs.." ")
elseif type(v) == "function" then
log1(subs..s..":function")
elseif type(v) == "userdata" then
if v.x and v.y and v.z then
log1(subs..s..":vector")
print_vector(v, subs.." ")
elseif v.k and v.j and v.i and v.c then
log1(subs..s..":matrix")
print_matrix(v, subs.." ")
elseif v.id and v.name then
if type(v.id) == "function" then
log1(subs..s..":game_object")
log1(subs.." "..v:name())
elseif type(v.id) == "number" then
log1(subs..s..":server_object")
log1(subs.." "..v:name())
else
log1(subs..s..":userdata")
end
else
log1(subs..s..":userdata")
end
else
log1(subs..s..":"..tostring(v))
end
end
end
-- печатаем вектор
function print_vector(v, subs)
log1((subs or "")..v.x..":"..v.y..":"..v.z)
end
-- печатаем матрицу
function print_matrix(m, subs)
print_vector(m.i, subs)
print_vector(m.j, subs)
print_vector(m.k, subs)
print_vector(m.c, subs)
end
-- class 'ini_file'
ini_file.r_string_ex = function (ini, section, line, def)
if ini:line_exist(section, line) then
return ini:r_string(section, line)
end
return def
end
ini_file.r_u32_ex = function (ini, section, line, def)
if ini:line_exist(section, line) then
return ini:r_u32(section, line)
end
return def
end
ini_file.r_float_ex = function (ini, section, line, def)
if ini:line_exist(section, line) then
return ini:r_float(section, line)
end
return def
end
ini_file.r_clsid_ex = function (ini, section, line)
if ini:line_exist(section, line) then
return ini:r_clsid(section, line)
end
return nil
end
ini_file.r_bool_ex = function (ini, section, line, def)
if ini:line_exist(section, line) then
return ini:r_bool(section, line)
end
return def
end
ini_file.r_list = function (ini, section, line, to_hash)
if ini:line_exist(section, line) then
local ret = string.explode( ini:r_string(section, line), ",", true )
if to_hash then
return table.tohash(ret)
else
return ret
end
end
return nil
end
ini_file.r_rect = function (ini, section, line)
if ini:line_exist(section, line) then
local t = {}
for n in string.gmatch(ini:r_string(section, line), "[%d%-%.]+") do
t[#t+1] = tonumber(n)
end
return Frect():set( unpack(t) )
end
return nil
end
-- class 'game_object'
-- volatile items
game_object.get_charge_level = function ( obj )
if sys_ini:r_bool_ex( obj:section(), "volatile", false ) == true then
local binder = obj:binded_object()
if binder and binder.get_charge_level then
return binder:get_charge_level()
end
return obj:condition()
end
return nil
end
-- CEntityAlive
game_object.is_alive = function( obj )
local cls = obj:clsid()
if ( IAmAStalker[ cls ] or IAmAMonster[ cls ] ) then
return obj:alive()
end
return cls == clsid.script_trader
end
game_object.is_wounded = function ( obj )
return obj:is_stalker() and obj:alive() and obj:wounded()
end
-- CAIStalker
-- получить видимость сталкера для аномалий
local anomaly_invisibility_flag = tonumber("80000000", 16)
game_object.get_anomaly_invisibility = function ( obj )
local fl = obj:get_actor_relation_flags()
return fl:test( anomaly_invisibility_flag )
end
-- установить видимость сталкера для аномалий
game_object.set_anomaly_invisibility = function ( obj, vis )
local fl = obj:get_actor_relation_flags()
fl:set( anomaly_invisibility_flag, vis )
obj:set_actor_relation_flags( fl )
end
-- CInventoryItem
-- вспомогательные функции для установки флагов в классе CInventoryItem
game_object.set_inventory_item_flags = function ( item, mask, value )
local flags = item:get_inventory_item_int16( nil, 132 )
flags = flags16():assign(flags):set(mask, value):get()
item:set_inventory_item_int16( 132, flags )
end
game_object.has_inventory_item_flags = function ( item, mask )
local flags = item:get_inventory_item_int16( nil, 132 )
return bit_and(flags, mask) ~= 0
end
game_object.set_custom_color_ids = function (item, col_idx)
ASSERT(col_idx >=0 and col_idx <=15, "[game_object.set_custom_color_ids] col_idx must be in the range [0-15]")
local fl = bit_or(bit_and(item:get_inventory_item_int16(nil, 134), 65520), col_idx)
item:set_inventory_item_int16(134, fl)
end
-- получить слот предмета
game_object.get_slot = function ( obj )
return obj:get_inventory_item_int( nil, 156 )
end
-- установить слот предмету
game_object.set_slot = function ( obj, slot )
obj:set_inventory_item_int( 156, slot )
end
-- установить цену предмету
game_object.set_cost = function ( obj, cost )
obj:set_inventory_item_int( 160, cost )
end
-- установить вес предмету
game_object.set_weight = function ( obj, weight )
obj:set_inventory_item_float(nil, weight, 164)
end
-- CWeaponAmmo
-- получить количество патронов в пачке
game_object.get_ammo_left = function( obj )
return obj:get_go_int16(nil, 476)
end
-- CWeapon
-- получить addon_flags оружия
game_object.get_addon_flags = function( obj )
return obj:get_wpn_int(nil, 936)
end
-- установить addon_flags оружию
game_object.set_addon_flags = function( obj, flags )
return obj:set_wpn_int(936, flags)
end
-- добавить флаг в addon_flags оружию
game_object.add_addon_flags = function( obj, flags )
local fl = obj:get_wpn_int(nil, 936)
local new_fl = bit_or(fl, flags)
return obj:set_wpn_int(936, new_fl)
end
-- получить индекс типа патронов
game_object.get_ammo_type = function( obj )
return obj:get_wpn_int(nil, 1444)
end
-- CPhysicShellHolder
-- возвращает имя кости по ее индексу
game_object.get_bone_name_by_id = function( obj, bone_id )
set_int_arg0(bone_id)
return obj:get_bone_name()
end
-- CCustomOutfit
game_object.get_power_loss = function( obj )
return obj:get_go_float(480)
end
game_object.set_power_loss = function( obj, v )
return obj:set_go_float(nil, v, 480)
end
game_object.get_additional_inventory_weight = function( obj )
return obj:get_go_float(500)
end
game_object.set_additional_inventory_weight = function( obj, v )
return obj:set_go_float(nil, v, 500)
end
game_object.get_additional_inventory_weight2 = function( obj )
return obj:get_go_float(504)
end
game_object.set_additional_inventory_weight2 = function( obj, v )
return obj:set_go_float(nil, v, 504)
end
-- class 'net_packet'
-- read
local CTime_0 = game.CTime()
net_packet.r_vec_q8 = function( pk )
return vector():set( pk:r_u8(), pk:r_u8(), pk:r_u8() )
end
net_packet.r_qt_q8 = function( pk )
return { x = pk:r_u8(), y = pk:r_u8(), z = pk:r_u8(), w = pk:r_u8() }
end
net_packet.r_u64 = function( pk )
return { pk:r_u8(), pk:r_u8(), pk:r_u8(), pk:r_u8(),
pk:r_u8(), pk:r_u8(), pk:r_u8(), pk:r_u8() }
end
net_packet.r_vu8u8 = function( pk )
local t = {}
for i = 1, pk:r_u8() do t[i] = pk:r_u8() end
return t
end
net_packet.r_vu32u8 = function( pk )
local t = {}
for i = 1, pk:r_s32() do t[i] = pk:r_u8() end
return t
end
net_packet.r_vu32u16 = function( pk )
local t = {}
for i = 1, pk:r_s32() do t[i] = pk:r_u16() end
return t
end
net_packet.r_tail = function( pk )
local t = {}
while not pk:r_eof() do t[#t+1] = pk:r_u8() end
return t
end
net_packet.r_CTime = function( pk )
local Y = pk:r_u8()
if Y ~= 0 then
local t = game.CTime()
local M, D, h, m, s, ms = pk:r_u8(), pk:r_u8(), pk:r_u8(), pk:r_u8(), pk:r_u8(), pk:r_u16()
t:set( Y + 2000, M, D, h, m, s, ms )
return t
else
return CTime_0
end
end
-- write
net_packet.w_vec_q8 = function( pk, v )
pk:w_u8( v.x ); pk:w_u8( v.y ); pk:w_u8( v.z )
end
net_packet.w_qt_q8 = function( pk, v )
pk:w_u8( v.x ); pk:w_u8( v.y ); pk:w_u8( v.z ); pk:w_u8( v.w )
end
net_packet.w_u64 = function( pk, v )
for i = 1, 8 do pk:w_u8( v[i] ) end
end
net_packet.w_vu8u8 = function( pk, v )
local n = #v
pk:w_u8( n )
for i = 1, n do pk:w_u8( v[i] ) end
end
net_packet.w_vu32u8 = function( pk, v )
local n = #v
pk:w_s32( n )
for i = 1, n do pk:w_u8( v[i] ) end
end
net_packet.w_vu32u16 = function( pk, v )
local n = #v
pk:w_s32( n )
for i = 1, n do pk:w_u16( v[i] ) end
end
net_packet.w_tail = function( pk, v )
for i, n in ipairs( v ) do
pk:w_u8( n )
end
end
net_packet.w_CTime = function( pk, v )
if v and v ~= CTime_0 then
local Y, M, D, h, m, s, ms = 0, 0, 0, 0, 0, 0, 0
Y, M, D, h, m, s, ms = v:get( Y, M, D, h, m, s, ms )
pk:w_u8 ( Y - 2000 ); pk:w_u8 ( M ); pk:w_u8 ( D )
pk:w_u8 ( h ); pk:w_u8 ( m ); pk:w_u8 ( s ); pk:w_u16( ms )
else
pk:w_u8 ( 0 )
end
end
-- class 'Frect'
Frect.mul = function ( rect, x, y )
if y==nil then y = x end
rect.x1 = rect.x1*x; rect.y1 = rect.y1*y;
rect.x2 = rect.x2*x; rect.y2 = rect.y2*y;
return rect
end
Frect.div = function ( rect, x, y )
if y==nil then y = x end
rect.x1 = rect.x1/x; rect.y1 = rect.y1/y;
rect.x2 = rect.x2/x; rect.y2 = rect.y2/y;
return rect
end
Frect.width = function ( rect )
return rect.x2 - rect.x1
end
Frect.height = function ( rect )
return rect.y2 - rect.y1
end
Frect.shrink = function ( rect, x, y )
rect.x1=rect.x1+x; rect.y1=rect.y1+y;
rect.x2=rect.x2-x; rect.y2=rect.y2-y;
return rect
end
Frect.grow = function ( rect, x, y )
rect.x1=rect.x1-x; rect.y1=rect.y1-y;
rect.x2=rect.x2+x; rect.y2=rect.y2+y;
return rect
end
Frect.intersected = function ( r1, r2 )
return r1.x1>r2.x2 or r1.x2<r2.x1 or r1.y1>r2.y2 or r1.y2<r2.y1
end
Frect.center = function ( rect )
return vector2():set(
(rect.x2 - rect.x1) /2,
(rect.y2 - rect.y1) /2
)
end
-- class 'CGameFont'
CGameFont.alVTop = 0
CGameFont.alVCenter = 1
CGameFont.alVBottom = 2
-- class 'CUIScriptWnd'
local wnd_id = 1
local registered_windows = {}
CUIScriptWnd.AddCallbackEx = function ( self, ui_name, ui_event, func, ... )
local id = self.__CUIScriptWnd_id
if id == nil then
id = wnd_id
wnd_id = wnd_id + 1
self.__CUIScriptWnd_id = id
registered_windows[ id ] = {}
registered_windows[ id ]["__window"] = self
end
if registered_windows[ id ][ ui_name ] == nil then
registered_windows[ id ][ ui_name ] = {}
end
registered_windows[ id ][ ui_name ][ ui_event ] = { ... }
self:AddCallback( ui_name, ui_event,
function ( i )
local t = registered_windows[ i ]
if t then
local wnd = t["__window"]
local p = t[ ui_name ][ ui_event ]
func( wnd, unpack( p ) )
else
log( "[CUIScriptWnd]: ignore callback for unregistered window %s: ui_name = %s, ui_event = %s",
i, ui_name, ui_event )
end
end,
id )
end
CUIScriptWnd.ClearCallbacks = function ( self )
local id = self.__CUIScriptWnd_id
if id == nil then
-- log("~ CUIScriptWnd.ClearCallbacks : __CUIScriptWnd_id not found" )
else
if self.__reg_childs then
for i, v in ipairs( self.__reg_childs ) do
registered_windows[ v ]["__window"] = nil
registered_windows[ v ] = nil
end
self.__reg_childs = nil
end
registered_windows[ id ]["__window"] = nil
registered_windows[ id ] = nil
end
-- log("CUIScriptWnd.ClearCallbacks [%s]: registered windows count [%d]", tostring(id), table.size(registered_windows) )
end
CUIScriptWnd.RegisterChild = function( self, child )
if child.__CUIScriptWnd_id == nil then return end
local id = self.__CUIScriptWnd_id
if id == nil then
id = wnd_id
wnd_id = wnd_id + 1
self.__CUIScriptWnd_id = id
registered_windows[ id ] = {}
registered_windows[ id ]["__window"] = self
-- log("CUIScriptWnd.RegisterChild: parent window has no __CUIScriptWnd_id" )
end
if self.__reg_childs == nil then
self.__reg_childs = {}
end
table.insert( self.__reg_childs, child.__CUIScriptWnd_id )
end
CUIScriptWnd.InitEditBoxEx = function ( self, stat, pos_x, pos_y, width, type )
local w = ui_edit_box_ru.CUIEditBox_new( stat, pos_x, pos_y, width, type )
self:RegisterChild( w )
return w
end
CUIScriptWnd.InitSpinNum = function ( self, stat, pos_x, pos_y, width, p )
local w = ui_spin_num.CUISpinNum( stat, pos_x, pos_y, width, p )
self:RegisterChild( w )
return w
end
CUIScriptWnd.InitSpinStr = function ( self, stat, pos_x, pos_y, width, p )
local w = ui_spin_str.CUISpinStr( stat, pos_x, pos_y, width, p )
self:RegisterChild( w )
return w
end
CUIScriptWnd.GetCursorPos = function ( self )
return vector2():set( self:GetCursorX(), self:GetCursorY() )
end
-- class 'CUIStatic'
CUIStatic.GetWndSize = function(wnd)
return vector2():set( wnd:GetWidth(), wnd:GetHeight() )
end
-- namespace 'level'
level.change_game_time = function (m, h, d) -- minutes, hours, days
level.advance_game_time((m or 0) * 60000 + (h or 0) * 3600000 + (d or 0) * 86400000)
end
level.vertex_id_by_pos = function ( position )
Actor:set_vector_global_arg_1( position )
return level.vertex_id()
end
level.__time_factor = sys_ini:r_u32("alife", "time_factor")
level.get_time_factor_old = level.get_time_factor
level.get_time_factor = function()
return level.__time_factor
end
level.set_time_factor_old = level.set_time_factor
level.set_time_factor = function(factor)
level.set_time_factor_old(factor)
level.__time_factor = factor
end
level.invalid_vertex_id = 4294967296
-- запускает эффектор шатания камеры с заданными параметрами
level.add_cam_effector3 = function(total_time, amplitude, period_number, power)
level.set_ce_time(total_time)
level.set_ce_amplitude(amplitude)
level.set_ce_period_number(period_number)
level.set_ce_power(power)
level.add_ce()
end
-- namespace 'relation_registry'
relation_registry.get_goodwill = function (who_id, to_whom_id)
return GetGoodwill(who_id, to_whom_id)
end
relation_registry.set_goodwill = function (who_id, to_whom_id, goodwill)
return Actor:set_goodwill_ex(who_id, to_whom_id, goodwill)
end
relation_registry.change_goodwill = function (who_id, to_whom_id, goodwill_change)
return Actor:change_goodwill_ex(who_id, to_whom_id, goodwill_change)
end
-- global functions
_G.old_user_name = user_name
_G.user_name = function( name )
if name == nil then
return game_options.UserName or old_user_name()
elseif type( name ) == "string" then
game_options.UserName = string.clear( name )
return true
end
log("! Wrong user name: %s", utils.to_str( name ) )
return false
end
--tmr:stop()
--log1( "# loading xray_extensions: "..tostring(tmr:time()) )