From a8adaa04043f2f1f2738bab9b40a95199b40cb54 Mon Sep 17 00:00:00 2001 From: Dr_Newbie Date: Mon, 24 Oct 2016 02:40:10 +0800 Subject: [PATCH] 11 ; Practice Driving https://youtu.be/lDlCULHHWdQ --- UnHackMe/lua/AchievmentManager.lua | 19 +++- lua/choose_safehouse.lua | 13 +++ lua/menu.lua | 25 ++++- lua/missionnow.lua | 2 +- ...VehicleManager_all_players_in_vehicles.lua | 3 + lua/press_that.lua | 103 +++++++++++++++++- mod.txt | 2 +- 7 files changed, 155 insertions(+), 12 deletions(-) create mode 100644 lua/overrides/VehicleManager_all_players_in_vehicles.lua diff --git a/UnHackMe/lua/AchievmentManager.lua b/UnHackMe/lua/AchievmentManager.lua index 942c321..45c1ac9 100644 --- a/UnHackMe/lua/AchievmentManager.lua +++ b/UnHackMe/lua/AchievmentManager.lua @@ -1,8 +1,15 @@ - --- This disables the triggering of achievments -function AchievmentManager:award(id, ...) - return +function AchievmentManager:award(id) + return end -function AchievmentManager:award_progress(stat, value, ...) - return +function AchievmentManager:_give_reward(id, skip_exp) + return end +function AchievmentManager:award_progress(stat, value) + return +end +function AchievmentManager:award_steam(id) + return +end +function AchievmentManager.steam_unlock_result(achievment) + return +end \ No newline at end of file diff --git a/lua/choose_safehouse.lua b/lua/choose_safehouse.lua index afe7514..aaafb31 100644 --- a/lua/choose_safehouse.lua +++ b/lua/choose_safehouse.lua @@ -28,6 +28,9 @@ function MenuManager:open_safehouse_menu() if DW and DW.Hooks then opts[#opts+1] = { text = "Spawn 'DW Plus'", callback_func = callback(self, self, "select_safehouse_adv_menu", {item = 11}) } end + if SafeHousePlus.settings.driving_test == 1 then + opts[#opts+1] = { text = "Play 'Practice Driving'", callback_func = callback(self, self, "select_safehouse_menu_driving_test", {}) } + end --opts[#opts+1] = { text = "Play 'Quick Shooting'", callback_func = callback(self, self, "select_safehouse_menu_spawn", {item = 101}) } if SafeHousePlus.settings.unit_tool == 1 then @@ -58,6 +61,16 @@ function mysplit(inputstr, sep) return t end +function MenuManager:select_safehouse_menu_driving_test() + local _default = "units/pd2_dlc_shoutout_raid/vehicles/fps_vehicle_muscle_1/fps_vehicle_muscle_1" + SafeHousePlus.EnemyType = SafeHousePlus.EnemyType or _default + if not tostring(SafeHousePlus.EnemyType):find("vehicles") then + SafeHousePlus.EnemyType = _default + end + SafeHousePlus:spawnsomething(Vector3(-425, 1150, 1050)) + managers.player:warp_to(Vector3(-85, 1000, 1050), Rotation(0, 0, 0)) +end + function MenuManager:select_safehouse_adv_menu(params) params.thisone = params.thisone or false params.item = params.item or 0 diff --git a/lua/menu.lua b/lua/menu.lua index f841ffb..6641737 100644 --- a/lua/menu.lua +++ b/lua/menu.lua @@ -17,7 +17,8 @@ _G.SafeHousePlus = _G.SafeHousePlus or {} nogameover_before_timeup = 0, difficulty = 7, multi_type = 0, - corpse_no_gone = 0 + corpse_no_gone = 0, + driving_test = 0 } SafeHousePlus.Difficulty = SafeHousePlus.Difficulty or "normal" @@ -45,6 +46,8 @@ _G.SafeHousePlus = _G.SafeHousePlus or {} ["safehouseplus_multi_type_menu_desc"] = "Enable spawn different type enemy.", ["safehouseplus_corpse_no_gone_menu_title"] = "Don't remove corpse", ["safehouseplus_corpse_no_gone_menu_desc"] = "Enable = Don't remove corpse", + ["safehouseplus_driving_test_menu_title"] = "Practice Driving", + ["safehouseplus_driving_test_menu_desc"] = "Allow you to practice driving", }) end) @@ -59,7 +62,8 @@ _G.SafeHousePlus = _G.SafeHousePlus or {} nogameover_before_timeout = 0, difficulty = 7, multi_type = 0, - corpse_no_gone = 0 + corpse_no_gone = 0, + driving_test = 0 } self:Save() end @@ -153,6 +157,23 @@ _G.SafeHousePlus = _G.SafeHousePlus or {} value = _bool, menu_id = SafeHousePlus.options_menu, }) + MenuCallbackHandler.set_safehouseplus_driving_test_toggle_callback = function(self, item) + if tostring(item:value()) == "on" then + SafeHousePlus.settings.driving_test = 1 + else + SafeHousePlus.settings.driving_test = 0 + end + SafeHousePlus:Save() + end + _bool = SafeHousePlus.settings.driving_test == 1 and true or false + MenuHelper:AddToggle({ + id = "set_safehouseplus_driving_test_toggle_callback", + title = "safehouseplus_driving_test_menu_title", + desc = "safehouseplus_driving_test_menu_desc", + callback = "set_safehouseplus_driving_test_toggle_callback", + value = _bool, + menu_id = SafeHousePlus.options_menu, + }) MenuCallbackHandler.set_safehouseplus_multi_type_toggle_callback = function(self, item) if tostring(item:value()) == "on" then SafeHousePlus.settings.multi_type = 1 diff --git a/lua/missionnow.lua b/lua/missionnow.lua index decf012..7113891 100644 --- a/lua/missionnow.lua +++ b/lua/missionnow.lua @@ -21,7 +21,7 @@ Hooks:PostHook(MissionManager, "init", "MissionManagerinit_PostHook", function(m tweak_data and tweak_data.narrative and tweak_data.levels and PackageManager and PackageManager:loaded("packages/game_base_init") and Global.game_settings and Global.game_settings.level_id == "chill" then - if SafeHousePlus.settings.vehicle_loaded == 1 then + if SafeHousePlus.settings.vehicle_loaded == 1 or SafeHousePlus.settings.driving_test == 1 then log("[SafeHousePlus] Vehicle Loaded") local _others_package = { "levels/narratives/bain/cage/world/world", "levels/narratives/vlad/shout/world/world", diff --git a/lua/overrides/VehicleManager_all_players_in_vehicles.lua b/lua/overrides/VehicleManager_all_players_in_vehicles.lua new file mode 100644 index 0000000..7d79278 --- /dev/null +++ b/lua/overrides/VehicleManager_all_players_in_vehicles.lua @@ -0,0 +1,3 @@ +function VehicleManager:all_players_in_vehicles() + return true +end \ No newline at end of file diff --git a/lua/press_that.lua b/lua/press_that.lua index 9edaa04..d318cfe 100644 --- a/lua/press_that.lua +++ b/lua/press_that.lua @@ -216,7 +216,9 @@ end function SafeHousePlus:spawnsomething(_pos, _dead_unit) _dead_unit = _dead_unit or nil local pos = SafeHousePlus.Spawn_Location.Human.pos - if _pos then pos = _pos end + if _pos then + pos = _pos + end if SafeHousePlus.settings.multi_type == 1 then local _multi = 0 for k, v in pairs(SafeHousePlus.EnemyType_Multi) do @@ -254,7 +256,10 @@ function SafeHousePlus:spawnsomething(_pos, _dead_unit) end if _is_vehicle then pos = SafeHousePlus.Spawn_Location.Vehicles.pos - end + if _pos then + pos = _pos + end + end if not _is_vehicle and not _spawn:find("characters") then log("[SafeHousePlus] Error, spawnsomething, _spawn: " .. tostring(_spawn)) end @@ -370,6 +375,100 @@ function SafeHousePlus:DoInit() if SafeHousePlus.settings.nogameover_before_timeup == 1 then SafeHousePlus:Spawn_One_AI({alone = 1}) end + if SafeHousePlus.settings.driving_test == 1 then + dofile(SafeHousePlus.ModPath .. "lua/overrides/VehicleManager_all_players_in_vehicles.lua") + local _driving_test_pos = { + {pos = Vector3(-745, 1160, 1000)}, + {pos = Vector3(-745, 1460, 1000)}, + {pos = Vector3(-745, 1760, 1000)}, + {pos = Vector3(-745, 2060, 1000)}, + {pos = Vector3(-745, 2360, 1000)}, + {pos = Vector3(-745, 2660, 1000)}, + {pos = Vector3(-745, 2960, 1000)}, + {pos = Vector3(-745, 3260, 1000)}, + {pos = Vector3(-745, 3560, 1000)}, + {pos = Vector3(-745, 3860, 1000)}, + {pos = Vector3(0, 1160, 1000)}, + {pos = Vector3(0, 1460, 1000)}, + {pos = Vector3(0, 1760, 1000)}, + {pos = Vector3(0, 2060, 1000)}, + {pos = Vector3(0, 2360, 1000)}, + {pos = Vector3(0, 2660, 1000)}, + {pos = Vector3(0, 2960, 1000)}, + {pos = Vector3(0, 3260, 1000)}, + {pos = Vector3(0, 3560, 1000)}, + {pos = Vector3(0, 3860, 1000)}, + {pos = Vector3(-1490, 1160, 1000)}, + {pos = Vector3(-1490, 1460, 1000)}, + {pos = Vector3(-1490, 1760, 1000)}, + {pos = Vector3(-1490, 2060, 1000)}, + {pos = Vector3(-1490, 2360, 1000)}, + {pos = Vector3(-1490, 2660, 1000)}, + {pos = Vector3(-1490, 2960, 1000)}, + {pos = Vector3(-1490, 3260, 1000)}, + {pos = Vector3(-1490, 3560, 1000)}, + {pos = Vector3(-1490, 3860, 1000)}, + {pos = Vector3(-2235, 1160, 1000)}, + {pos = Vector3(-2235, 1460, 1000)}, + {pos = Vector3(-2235, 1760, 1000)}, + {pos = Vector3(-2235, 2060, 1000)}, + {pos = Vector3(-2235, 2360, 1000)}, + {pos = Vector3(-2235, 2660, 1000)}, + {pos = Vector3(-2235, 2960, 1000)}, + {pos = Vector3(-2235, 3260, 1000)}, + {pos = Vector3(-2235, 3560, 1000)}, + {pos = Vector3(-2235, 3860, 1000)}, + {pos = Vector3(-2235, 860, 1000)}, + {pos = Vector3(-2235, 560, 1000)}, + {pos = Vector3(-2235, 260, 1000)}, + {pos = Vector3(-2235, -40, 1000)}, + {pos = Vector3(-2235, -340, 1000)}, + {pos = Vector3(-2235, -640, 1000)}, + {pos = Vector3(-2235, -940, 1000)}, + {pos = Vector3(-2235, -1240, 1000)}, + {pos = Vector3(-1490, -1240, 1000)}, + {pos = Vector3(-745, -1240, 1000)}, + {pos = Vector3(0, -1240, 1000)}, + {pos = Vector3(745, -1240, 1000), rot = Rotation(0, 90, -20)}, + {pos = Vector3(1445, -1240, 1255), rot = Rotation(0, 90, -20)}, + {pos = Vector3(2145, -1240, 1510), rot = Rotation(0, 90, -20)}, + {pos = Vector3(2845, -1240, 1765), rot = Rotation(0, 90, -20)}, + {pos = Vector3(3545, -1240, 2020), rot = Rotation(0, 90, -20)}, + {pos = Vector3(4245, -1240, 2275)}, + {pos = Vector3(4245, -940, 2275)}, + {pos = Vector3(4245, -640, 2275)}, + {pos = Vector3(4245, -340, 2275)}, + {pos = Vector3(4245, -40, 2275)}, + {pos = Vector3(4245, 260, 2275)}, + {pos = Vector3(4245, 560, 2275)}, + {pos = Vector3(4245, 860, 2275)}, + {pos = Vector3(4245, 1160, 2275)}, + {pos = Vector3(4245, 1460, 2275)}, + {pos = Vector3(4245, 1760, 2275)}, + {pos = Vector3(745, 1760, 1000), rot = Rotation(0, 90, -20)}, + {pos = Vector3(1445, 1760, 1255), rot = Rotation(0, 90, -20)}, + {pos = Vector3(2145, 1760, 1510), rot = Rotation(0, 90, -20)}, + {pos = Vector3(2845, 1760, 1765), rot = Rotation(0, 90, -20)}, + {pos = Vector3(3545, 1760, 2020), rot = Rotation(0, 90, -20)}, + {pos = Vector3(4245, 2060, 2275)}, + {pos = Vector3(4245, 2360, 2275)}, + {pos = Vector3(4245, 2660, 2275)}, + {pos = Vector3(4245, 2960, 2275)}, + {pos = Vector3(4245, 3260, 2275)}, + {pos = Vector3(4245, 3560, 2275)}, + {pos = Vector3(4245, 3860, 2275)}, + {pos = Vector3(4245, 4160, 2275)}, + {pos = Vector3(4245, 4460, 2275)}, + {pos = Vector3(3545, 4460, 2020), rot = Rotation(0, 90, -20)}, + } + local _driving_test_unit_name = Idstring("units/payday2/props/air_prop_runway_fence/air_prop_runway_fence_gate_v3") + for _, v in pairs(_driving_test_pos) do + _u = safe_spawn_unit(_driving_test_unit_name, v.pos, v.rot or Rotation(0, 90, 0)) + if _u and alive(_u) and _u:interaction() then + _u:interaction():set_active(false, false) + end + end + end log("[SafeHousePlus] DoInit") end end diff --git a/mod.txt b/mod.txt index 59549c1..b63f95a 100644 --- a/mod.txt +++ b/mod.txt @@ -2,7 +2,7 @@ "name":"SafeHouse Plus", "author":"Dr_Newbie", "contact":"Allow you open other difficulty safehouse, give you real target shooting and do some customization.", - "version":"10", + "version":"11", "hooks":[ {"hook_id":"core/lib/managers/mission/coremissionscriptelement", "script_path":"lua/event.lua"}, {"hook_id":"lib/managers/localizationmanager", "script_path":"lua/swap_weapon/function.lua"},