Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Handler for scripted keybinds
- -- keybind_name = default
- -- To add new keybinds, simplay add name here and default keypress. Then make an action.<name> function for it. Param passed is true if pressed or false if released
- local keybinds = {
- ["companion_cycle_combat_mode"] = "DIK_NUMPAD1",
- ["companion_cycle_move_mode"] = "DIK_NUMPAD2",
- ["companion_move_to_point"] = "DIK_NUMPAD3",
- ["debug_demo_record"] = "DIK_NUMPAD0",
- ["debug_select_object"] = "DIK_NUMPAD9",
- ["debug_attachment_ui"] = "DIK_INSERT",
- ["debug_test"] = "DIK_NUMPADENTER",
- ["debug_reload_game"] = "DIK_END",
- ["debug_hold_action"] = "DIK_NUMPAD8",
- ["photo_increase_middlegray"] = "DIK_ADD",
- ["photo_decrease_middlegray"] = "DIK_SUBTRACT"
- }
- local action = {}
- local middlegray_value = 1.0
- ------------------------------------------------------------------
- -- Keypress actions
- ------------------------------------------------------------------
- function action.companion_cycle_combat_mode(p)
- if (p==1) then
- axr_companions.cycle_companions_combat_mode()
- end
- end
- function action.companion_cycle_move_mode(p)
- if (p==1) then
- axr_companions.cycle_companions_move_mode()
- end
- end
- function action.companion_move_to_point(p)
- axr_companions.move_to_point(p)
- end
- function action.debug_demo_record(p)
- if not (DEV_DEBUG) then
- return
- end
- if (p==1) then
- get_console():execute("demo_record t")
- end
- end
- function action.debug_attachment_ui(p)
- if not (DEV_DEBUG) then
- return
- end
- if (p==1) then
- if not (this.debug_ui_attach) then
- this.debug_ui_attach = ui_debug_main.debug_ui_attach()
- end
- if (this.debug_ui_attach) then
- if not (this.debug_ui_attach:IsShown()) then
- this.debug_ui_attach:ShowDialog(true)
- else
- this.debug_ui_attach:HideDialog()
- end
- end
- end
- end
- function action.debug_select_object(p)
- if not (DEV_DEBUG) then
- return
- end
- if (p==1) then
- DEBUG_NPC = level.get_target_obj and level.get_target_obj()
- if (DEBUG_NPC) then
- SetHudMsg(strformat("%s Hold then release key to new position",DEBUG_NPC:name()),8)
- end
- elseif (p==0) then
- if (DEBUG_NPC) then
- local r = level.get_target_dist and level.get_target_dist()
- if (r) then
- if (IsStalker(DEBUG_NPC) or IsMonster(DEBUG_NPC)) then
- local lvid = level.vertex_in_direction(level.vertex_id(device().cam_pos),device().cam_dir,r)
- if (lvid) then
- DEBUG_NPC:set_npc_position(level.vertex_position(lvid))
- end
- else
- local pos = vector():set(device().cam_pos)
- pos:add(device().cam_dir:mul(r))
- local lvid = level.vertex_id(pos)
- if (lvid < 4294967295) then
- TeleportObject(DEBUG_NPC:id(),pos,lvid,db.actor:game_vertex_id())
- else
- SetHudMsg("Position not on AI Map",4)
- end
- end
- end
- SetHudMsg("",1)
- end
- end
- end
- function action.debug_test(p)
- if not (DEV_DEBUG) then
- return
- end
- if (p==2) then
- local obj = level.get_target_obj and level.get_target_obj()
- if ( obj ) then
- SetHudMsg( strformat("Object: %s", obj:name()),8)
- end
- -- local se_obj = alife():object(obj:id())
- -- if (se_obj) then
- -- RELEASES TASK GIVER FOR ALL TASKS WITH task_giver_id; useful for testing how a task works when giver is dead
- --[[
- local debug_task_infos = task_manager.get_task_manager().task_info
- local task_ini = task_manager.task_ini
- for k,v in pairs(debug_task_infos) do
- local squad = v.task_giver_id and alife():object(v.task_giver_id)
- if (squad) then
- if (squad:clsid() == clsid.online_offline_group_s) then
- printf("%s removing squad task giver!",k)
- SIMBOARD:assign_squad_to_smart(squad, nil)
- squad:remove_squad()
- elseif (IsStalker(squad)) then
- printf("%s removing npc task giver!",k)
- alife():release(squad,true)
- end
- end
- end
- --]]
- -- SET ALL ACTIVE TASKS TO COMPLETE STAGE
- --[[
- local debug_task_infos = task_manager.get_task_manager().task_info
- local task_ini = task_manager.task_ini
- for k,v in pairs(debug_task_infos) do
- local stage = tonumber(utils.cfg_get_string(task_ini, k, "stage_complete", nil, false, "")) or 0
- if (stage > 0 and stage ~= 255) then
- v.stage = stage
- end
- end
- --]]
- -- test
- --[[
- local function spawn_in_front_quadrant(sec)
- local base_point = db.actor:level_vertex_id()
- local dist = math.random(15,25)
- local dir = device().cam_dir
- local spawn_lvid, ang, new_dir
- while (spawn_lvid == nil or spawn_lvid >= 4294967295 or dist <= 1) do
- ang = math.random(-50,50)
- new_dir = vector_rotate_y(utils.vector_copy_by_val(dir),ang)
- spawn_lvid = level.vertex_in_direction(base_point, new_dir, dist)
- dist = dist - 2
- end
- if (spawn_lvid and spawn_lvid < 4294967295) then
- alife():create(sec,level.vertex_position(spawn_lvid),spawn_lvid,db.actor:game_vertex_id())
- end
- end
- spawn_in_front_quadrant("wpn_pm")
- --]]
- elseif (p==0) then
- SetHudMsg("",1)
- end
- end
- function action.debug_reload_game(p)
- -- Reloads game files in-game so that application does not need restart
- if not (DEV_DEBUG) then
- return
- end
- if (p==0) then
- local fs = getFS()
- fs:rescan_path('$game_config$')
- fs:rescan_path('$game_scripts$')
- reload_system_ini()
- local p = net_packet()
- p:w_begin(15) -- reload game
- level.send(p,true)
- end
- end
- function action.debug_hold_action(p)
- if (p == 1) then
- _G.DEV_DEBUG_HOLD_ACTION_1 = true
- local squad
- local sim = alife()
- for i=1,65534 do
- squad = sim:object(i)
- if (squad and squad:clsid() == clsid.online_offline_group_s) then
- if (squad.first_update) then
- squad:hide()
- end
- end
- end
- elseif (p == 0) then
- _G.DEV_DEBUG_HOLD_ACTION_1 = false
- end
- end
- function action.photo_increase_middlegray( p )
- if ( p == 1 ) then
- middlegray_value = middlegray_value + 0.1
- if ( middlegray_value > 2 ) then
- middlegray_value = 2
- end
- get_console():execute("r2_tonemap_middlegray " .. middlegray_value )
- SetHudMsg( strformat("Middlegray set to: %s", middlegray_value ), 8 )
- elseif ( p == 0 ) then
- SetHudMsg("", 1 )
- end
- end
- function action.photo_decrease_middlegray( p )
- if ( p == 1 ) then
- middlegray_value = middlegray_value - 0.1
- if ( middlegray_value < 0 ) then
- middlegray_value = 0
- end
- get_console():execute("r2_tonemap_middlegray " .. middlegray_value )
- SetHudMsg( strformat("Middlegray set to: %s", middlegray_value ), 8 )
- elseif ( p == 0 ) then
- SetHudMsg("", 1 )
- end
- end
- -------------------------------------------
- -- callbacks
- -------------------------------------------
- local function on_key_release(key)
- for k,v in pairs(keybinds) do
- if (action[k] and key == DIK_keys[axr_main.config:GetValue("global_keybinds",k,0,"")]) then
- action[k](0)
- end
- end
- end
- local function on_key_press(key)
- for k,v in pairs(keybinds) do
- if (action[k] and key == DIK_keys[axr_main.config:GetValue("global_keybinds",k,0,"")]) then
- action[k](1)
- end
- end
- end
- local function on_key_hold(key)
- for k,v in pairs(keybinds) do
- if (action[k] and key == DIK_keys[axr_main.config:GetValue("global_keybinds",k,0,"")]) then
- action[k](2)
- end
- end
- end
- function on_game_start()
- RegisterScriptCallback("on_key_press",on_key_press)
- RegisterScriptCallback("on_key_release",on_key_release)
- RegisterScriptCallback("on_key_hold",on_key_hold)
- local need_save
- for k,v in pairs(keybinds) do
- if not (axr_main.config:KeyExist("global_keybinds",k)) then
- axr_main.config:SetValue("global_keybinds",k,v)
- need_save = true
- end
- end
- if (need_save) then
- axr_main.config:Save()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement