diff --git a/scripts/re3_weapon_position.lua b/scripts/re3_weapon_position.lua new file mode 100644 index 000000000..fbffaf32c --- /dev/null +++ b/scripts/re3_weapon_position.lua @@ -0,0 +1,49 @@ +do return end -- remove this line to enable + +if reframework:get_game_name() ~= 're3' then + return +end + +local re2 = require('utility/RE2') + +--[[ +Common OpenVR +default: 0.2, -2.5, -1.7 +handgun: 0.2, -2.5, -1.7 + +Common OpenXR +default: 0.28, -2.982, -1.495 +handgun: 0.28, -2.982, -1.495 + +HP Reverb G2 OpenXR +default: 0.28, -2.62, -2.3 +handgun: 0, -2.62, -1.8 +]]-- +local default_right_hand_rotation_vec = Vector3f.new(0.28, -2.982, -1.495) +local handgun_right_hand_rotation_vec = Vector3f.new(0.28, -2.982, -1.495) + +-- https://github.com/SilverEzredes/Advanced-Weapon-Framework/blob/master/AWFCore/AWF/RE3R_WeaponData.lua +local handguns = {'wp0000', 'wp0100', 'wp0200', 'wp0300', 'wp0600', 'wp3000', 'wp3100'} + +re.on_pre_application_entry('UpdateBehavior', function() + if not re2.weapon then + return + end + + local weapon_gameobject = re2.weapon:call('get_GameObject') + + if not weapon_gameobject then + return + end + + local weapon_name = weapon_gameobject:call('get_Name') + + for i = 1, #handguns do + if weapon_name == handguns[i] then + firstpersonmod.right_hand_rotation_offset = handgun_right_hand_rotation_vec + return + end + end + + firstpersonmod.right_hand_rotation_offset = default_right_hand_rotation_vec +end) \ No newline at end of file diff --git a/src/mods/FirstPerson.cpp b/src/mods/FirstPerson.cpp index 71c87795e..c6a7ade49 100644 --- a/src/mods/FirstPerson.cpp +++ b/src/mods/FirstPerson.cpp @@ -231,7 +231,8 @@ void FirstPerson::on_lua_state_created(sol::state& state) { "new", sol::no_constructor, "is_enabled", &FirstPerson::is_enabled, "will_be_used", &FirstPerson::will_be_used, - "on_pre_flashlight_apply_transform", &FirstPerson::on_pre_flashlight_apply_transform + "on_pre_flashlight_apply_transform", &FirstPerson::on_pre_flashlight_apply_transform, + "right_hand_rotation_offset", &FirstPerson::m_right_hand_rotation_offset ); state["firstpersonmod"] = this;