0% found this document useful (0 votes)
56 views4 pages

Recoil Control Script for FPS Weapons

The document contains a script for managing weapon recoil patterns in a shooting game, detailing various weapons and their respective recoil characteristics. It includes functions for weapon switching, auto-fire toggling, and scoped shooting, along with the main shooting logic that incorporates recoil control based on the selected weapon. The recoil patterns are defined in a table, allowing for dynamic adjustments during gameplay.

Uploaded by

dwivedinaman2004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views4 pages

Recoil Control Script for FPS Weapons

The document contains a script for managing weapon recoil patterns in a shooting game, detailing various weapons and their respective recoil characteristics. It includes functions for weapon switching, auto-fire toggling, and scoped shooting, along with the main shooting logic that incorporates recoil control based on the selected weapon. The recoil patterns are defined in a table, allowing for dynamic adjustments during gameplay.

Uploaded by

dwivedinaman2004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

EnablePrimaryMouseButtonEvents(true)

-- Define recoil patterns based on the provided data

local recoil_table = {

vandal = {x = 1, y = 5, delay = 100, bullets_before_recoil = 4, pattern = {{x=0, y=5}, {x=1,


y=5}, {x=-1, y=5}}},

phantom = {x = 1, y = 4, delay = 100, bullets_before_recoil = 5, pattern = {{x=0, y=4}, {x=1,


y=4}, {x=-1, y=4}}},

bulldog = {x = 1, y = 4, delay = 90, bullets_before_recoil = 3, pattern = {{x=0, y=4}, {x=0,


y=4}, {x=0, y=4}}},

spectre = {x = 1, y = 3, delay = 80, bullets_before_recoil = 6, pattern = {{x=0, y=3}, {x=1,


y=3}, {x=-1, y=3}, {x=1, y=3}}},

odin = {x = 1, y = 4, delay = 75, bullets_before_recoil = 10, pattern = {{x=0, y=4}, {x=1,


y=4}, {x=-1, y=4}}},

ares = {x = 1, y = 4, delay = 80, bullets_before_recoil = 9, pattern = {{x=0, y=4}, {x=1,


y=4}, {x=-1, y=4}}}

-- Initial Settings

local current_weapon = "vandal"

local is_auto_fire = false

local is_scoped = false

function OnEvent(event, arg)

-- Weapon Switching

if event == "MOUSE_BUTTON_PRESSED" then

if arg == 6 then

current_weapon = "phantom"

elseif arg == 7 then

current_weapon = "vandal"
elseif arg == 8 then

current_weapon = "spectre"

elseif arg == 9 then

current_weapon = "bulldog"

elseif arg == 10 then

current_weapon = "ares"

elseif arg == 11 then

current_weapon = "odin"

end

end

-- Auto Fire Toggle (Mouse 3)

if event == "MOUSE_BUTTON_PRESSED" and arg == 3 then

is_auto_fire = not is_auto_fire

end

-- Quick Scope (Right-click)

if event == "MOUSE_BUTTON_PRESSED" and arg == 2 then

is_scoped = true

PressMouseButton(2)

Sleep(50) -- Scope delay

ReleaseMouseButton(2)

Sleep(150) -- Extra delay before firing

elseif event == "MOUSE_BUTTON_RELEASED" and arg == 2 then

is_scoped = false

end

-- Main Shooting Logic


if event == "MOUSE_BUTTON_PRESSED" and arg == 1 then

if is_scoped then

repeat

PressMouseButton(1)

Sleep(200)

ReleaseMouseButton(1)

Sleep(200)

until not IsMouseButtonPressed(1)

elseif is_auto_fire then

repeat

PressMouseButton(1)

Sleep(120)

ReleaseMouseButton(1)

Sleep(120)

until not IsMouseButtonPressed(1)

else

-- Recoil Control for Normal Shooting

local weapon = recoil_table[current_weapon]

if weapon then

local bullet_count = 0

repeat

if IsMouseButtonPressed(1) then

bullet_count = bullet_count + 1

if bullet_count > weapon.bullets_before_recoil then

local recoil_pattern = [Link] or {{x=0, y=weapon.y}}


local index = (bullet_count - weapon.bullets_before_recoil) %
#recoil_pattern + 1

local pattern = recoil_pattern[index]

MoveMouseRelative(pattern.x, pattern.y)

end

Sleep([Link])

end

until not IsMouseButtonPressed(1)

end

end

end

end

You might also like