Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mod_name = "SprayFix"
- local user_setting = Application.user_setting
- local MOD_SETTINGS = {
- ENABLED = {
- ["save"] = "cb_spray_fix",
- ["widget_type"] = "stepper",
- ["text"] = "Drake And Beam Fix",
- ["tooltip"] = "Drake And Beam Fix\n" ..
- "Drake and beam will prioritize nearer rats.",
- ["value_type"] = "boolean",
- ["options"] = {
- {text = "Off", value = false},
- {text = "On", value = true},
- },
- ["default"] = 1, -- Off
- },
- }
- local POSITION_TWEAK = -1
- local SPRAY_RANGE = math.abs(POSITION_TWEAK) + 5
- local SPRAY_RADIUS = 3.5
- local PLAYER_SPRAY_RADIUS = 2
- local MAX_TARGETS = 10
- local NODES = {
- "j_leftshoulder",
- "j_rightshoulder",
- "j_spine"
- }
- Mods.hook.set(mod_name, "ActionBulletSpray._select_targets", function (func, self, world, show_outline)
- if not user_setting(MOD_SETTINGS.ENABLED.save) then
- func(self, world, show_outline)
- return
- end
- local owner_unit_1p = self.owner_unit_first_person
- local player_position = POSITION_LOOKUP[owner_unit_1p]
- local player_rotation = Unit.world_rotation(owner_unit_1p, 0)
- local player_direction = Vector3.normalize(Quaternion.forward(player_rotation))
- local start_point = player_position + player_direction*POSITION_TWEAK + player_direction*SPRAY_RADIUS
- local original_PhysicsWorld_linear_sphere_sweep = PhysicsWorld.linear_sphere_sweep
- PhysicsWorld.linear_sphere_sweep = function(...)
- local results = original_PhysicsWorld_linear_sphere_sweep(...)
- table.sort(results,
- function(hit1, hit2)
- return Vector3.distance(player_position, Unit.local_position(Actor.unit(hit1.actor), 0)) < Vector3.distance(player_position, Unit.local_position(Actor.unit(hit2.actor), 0))
- end
- )
- return results
- end
- func(self, world, show_outline)
- PhysicsWorld.linear_sphere_sweep = original_PhysicsWorld_linear_sphere_sweep
- end)
- --- options
- local function create_options()
- Mods.option_menu:add_group("spray_fix_group", "Drake And Beam Fix")
- Mods.option_menu:add_item("spray_fix_group", MOD_SETTINGS.ENABLED, true)
- end
- safe_pcall(create_options)
Advertisement
Add Comment
Please, Sign In to add comment