Skip to content

Instantly share code, notes, and snippets.

@vinevi
Last active Apr 24, 2021
Embed
What would you like to do?
MM6 - MMExtension - Camera Zoom (outdoor only)
local fovManager = {
FOV = 170,
increment = 4,
timer = nil
}
fovManager.update = function(self)
local hexFOV = '0x' .. bit.tohex(self.FOV);
mem.asmpatch(0x004789f5, 'AND EAX, ' .. hexFOV);
mem.call(0x004582cd)
Game.ShowStatusText('FOV updated: ' .. self.FOV)
end
fovManager.add = function(self)
self:to( self.FOV - self.increment )
end
fovManager.substract = function(self)
self:to( self.FOV + self.increment )
end
fovManager.set = function(self, value)
self.FOV = math.min(math.max(value, 10), 300)
self:update()
end
fovManager.to = function(self, value)
RemoveTimer(self.timer)
local increment = self.increment
local forward = value > self.FOV
self.timer = function()
local newFOV = self.FOV
if(forward == true) then
newFOV = newFOV + self.increment
if(newFOV > value) then
newFOV = value
end
else
newFOV = newFOV - self.increment
if(newFOV < value) then
newFOV = value
end
end
self:set( newFOV )
if(newFOV == value) then
RemoveTimer(self.timer)
end
end
Timer(self.timer, const.Second)
end
fovManager.raiseTextureQualityDistance = function(self)
-- low distance
mem.asmpatch( 0x004581f1, [[
MOV ESI,0x2000
]] )
-- medium distance
mem.asmpatch( 0x004581dd, [[
MOV EDX,0x3000
]] )
-- high distance
mem.asmpatch( 0x004581e2, [[
MOV ECX,0x4000
]] )
end
fovManager.init = function(self)
function Keys.P(t)
self:add()
end
function Keys.O(t)
self:substract()
end
function Keys.L(t)
self:to(60)
end
function Keys.K(t)
self:to(170)
end
function Keys.J(t)
self:to(220)
end
self:raiseTextureQualityDistance()
end
fovManager:init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment