Lerk Free Aim
Soul_Rider
Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
There was a request made in Agiel's Free-Aim mod to make the free-aim ability available for the lerk. I have coded it, using the base of Agiel's mod.
<u>*Updated to Version 3*</u>
Working free aim with default crosshair for spikes
Working free aim without crosshair for spores (doesn't need a cross hair it's not ranged)
Play away to your hearts content. Values can be adjusted but the box size works for me on 16:9.
<u>*Updated to Version 2*</u>
Current Status:
Free Aim for Lerk Spikes and Lerk Spores
Spores have no crosshairs
Spikes crosshair does not follow the free aim and stays centered in the screen.
Here I present Lerk Free Aim:
V1:
<center><object width="450" height="356"><param name="movie" value="http://www.youtube.com/v/AYIDd82fjZ8"></param><embed src="http://www.youtube.com/v/AYIDd82fjZ8" type="application/x-shockwave-flash" width="450" height="356"></embed></object></center>
The only issue so far is the crosshair doesn't move with the aim.
Works well and is a definite fun feature for the lerk. May need to expand the freeaim boundary. :)
Download Here:
<a href="http://www.duplexgaming.co.uk/downloads/mods/73/lerk_free_aim/" target="_blank">http://www.duplexgaming.co.uk/downloads/mo.../lerk_free_aim/</a>
Comments and suggestions, and help with getting the cursor moving all appreciated :
<u>*Updated to Version 3*</u>
Working free aim with default crosshair for spikes
Working free aim without crosshair for spores (doesn't need a cross hair it's not ranged)
Play away to your hearts content. Values can be adjusted but the box size works for me on 16:9.
<u>*Updated to Version 2*</u>
Current Status:
Free Aim for Lerk Spikes and Lerk Spores
Spores have no crosshairs
Spikes crosshair does not follow the free aim and stays centered in the screen.
Here I present Lerk Free Aim:
V1:
<center><object width="450" height="356"><param name="movie" value="http://www.youtube.com/v/AYIDd82fjZ8"></param><embed src="http://www.youtube.com/v/AYIDd82fjZ8" type="application/x-shockwave-flash" width="450" height="356"></embed></object></center>
The only issue so far is the crosshair doesn't move with the aim.
Works well and is a definite fun feature for the lerk. May need to expand the freeaim boundary. :)
Download Here:
<a href="http://www.duplexgaming.co.uk/downloads/mods/73/lerk_free_aim/" target="_blank">http://www.duplexgaming.co.uk/downloads/mo.../lerk_free_aim/</a>
Comments and suggestions, and help with getting the cursor moving all appreciated :
Comments
I have added free aim to spores.
I am unable to fix crosshair movement issue at the moment, so for spores I have removed the crosshair, as it's not a ranged attack, there is no need for it, and the view model movement clearly shows what direction your spores are going.
Any help with why the crosshair is not moving is greatly appreciated :)
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Script.Load("../ns2/lua/GUICrosshair.lua")
// Update crosshair position
if GUICrosshair.BaseUpdate == nil then
GUICrosshair.BaseUpdate = GUICrosshair.Update
end
function GUICrosshair:Update(deltaTime)
self:BaseUpdate(deltaTime)
// FREEAIM:
self.crosshairs:SetPosition(Vector(
-GUICrosshair.kCrosshairSize / 2 + PlayerUI_GetCrosshairOffsetX(),
-GUICrosshair.kCrosshairSize / 2 + PlayerUI_GetCrosshairOffsetY(),
0))
end<!--c2--></div><!--ec2-->
Comparing to your code:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function GUICrosshair:Update(deltaTime)
PROFILE("GUICrosshair:Update")
// Update crosshair image.
local xCoord = PlayerUI_GetCrosshairX()
local yCoord = PlayerUI_GetCrosshairY()
self.crosshairs:SetIsVisible(true)
self.crosshairs:SetColor(GUICrosshair.kInvisibleColor)
if PlayerUI_GetCrosshairWidth() == 0 then
self.crosshairs:SetColor(GUICrosshair.kInvisibleColor)
elseif xCoord and yCoord then
self.crosshairs:SetColor(GUICrosshair.kVisibleColor)
self.crosshairs:SetTexturePixelCoordinates(xCoord, yCoord,
xCoord + PlayerUI_GetCrosshairWidth(), yCoord + PlayerUI_GetCrosshairHeight())
end
// FREEAIM:
self.crosshairs:SetPosition(Vector(
-GUICrosshair.kCrosshairSize / 2 + PlayerUI_GetCrosshairOffsetX(),
-GUICrosshair.kCrosshairSize / 2 + PlayerUI_GetCrosshairOffsetY(),
0))
// Update crosshair text.
...
// Update give damage indicator.
...
end<!--c2--></div><!--ec2-->
At the very least, these lines are missing:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->if GUICrosshair.BaseUpdate == nil then
GUICrosshair.BaseUpdate = GUICrosshair.Update
end
...
self:BaseUpdate(deltaTime)<!--c2--></div><!--ec2-->
but... they don't seem to do much?
Ehh... gotta look at " PlayerUI_GetCrosshairOffsetX() " these as well I guess. Hmm, but you've got that too.
He is calling this function:
function GUICrosshair:Update(deltaTime)
He is making his function self:BaseUpdate() a sub class of GUICrosshair:Update. In my code I added it directly to the GUICrosshair:Update code, thus eliminating the need for a separate sublclassed file.
Again, I added both of those function to the main file, rather than extending the class into a sub file.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// FREEAIM: Add offsets if weapon uses free aim.
local weapon = self:GetActiveWeapon()
if(weapon ~= nil and weapon.kUsesFreeAim) then
viewAngles.yaw = viewAngles.yaw + self.freeAimYawOffset
viewAngles.pitch = viewAngles.pitch + self.freeAimPitchOffset
end<!--c2--></div><!--ec2-->after <i>local viewAngles = self:GetViewAngles()</i>
The new fov calculations also mess up the crosshair position in 5:4 resolutions since the effective fov there is more like 70 instead of 90, but I guess that'll be fixed in the next build. Actually, I'm not sure if the lerk uses fov 90. You might need to do something like
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->local angleScale = 90 / player:GetFov()
return math.sin(-player.freeAimYawOffset*angleScale) * Client.GetScreenWidth() / 2<!--c2--></div><!--ec2-->when the crosshair offsets are calculated.
I also realized we have a problem with gimbal lock when looking far up or down. Don't have an easy fix for that yet.
This isn't a fov issue, the view model works, the fire angles of the spikes and the spores is correct, it's just the crosshair stays rooted to the centre of the screen.
It's almost like it is not picking up on the freeaim code in GUICrosshair. Either that or the alien crosshair is actually a full screen transparency with just the icon in the middle :P
The current issue I have with not making the cursor follow the free aim is a perfect opportunity to explain how this mod does not affect movement.
Currently the crosshair is fixed in the centre of the screen as normal, but the free aim is working on the view model, and the spikes, as you can clearly see.
What you can also clearly see is that whenever I move the mouse, although there is accelerated movement from the weapons, the cursor in the centre of the screen moves exactly as you expect.
In this video you see the lerk flying, firing off target because of the free aim, but the crosshair in the centre of the screen is movement direction as controlled by the mouse. Flying issues are caused by the 15fps rather than free aim :)
<center><object width="450" height="356"><param name="movie" value="http://www.youtube.com/v/FWxC9z96nIw"></param><embed src="http://www.youtube.com/v/FWxC9z96nIw" type="application/x-shockwave-flash" width="450" height="356"></embed></object></center>
So this lead me to an idea, how about implementing a 'dual' crosshair, at least initially while people learn the nuances of lerk free aim.
How about keeping a tiny centre crosshair, like the dot i'm using, always in the centre of the screen, to help with understanding flight direction (although really it's not very confusing), and add a secondary outer crosshair that moves with the free aim of the spikes?
Let me know thoughts on that :)
-----EDIT------
As a test, deleted the code from GUICrosshair, and just used the vanilla NS2 file with your extension, but still the same issue, so I can rule out the GUICrosshair file. There are no code errors, the code is solid, but the effect we desire is not forthcoming :P
<img src="http://i.imgur.com/HOs8O.png" border="0" class="linked-image" />
Above: rotationally stationary
Below: rotationally in motion
Blue is the movement crosshair, and is stationary with the view.
Red is the aim crosshair, and is independent of the view.
I forgot that previously, when testing your mod, I was implementing a console command to enable freeaim, lol, somehow i've used part of that code, hahaha. Right, kFreeAimOn = true kind of works :)
I have free aim cursor on vertical up and down movements, but not horizontal. :P
Gonna check it out now :) Adding your FOV code to test.
Still not working on the horizontal.
Here is the code for the crosshair offsets:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// Get crosshair X position
function PlayerUI_GetCrosshairOffsetX()
local player = Client.GetLocalPlayer()
if(player and not player:GetIsThirdPerson()) and KFreeAimOn == true then
local weapon = player:GetActiveWeapon()
if(weapon ~= nil and weapon.kUsesFreeAim) then
// Don't ask me why this works. afaik sin(45) isn't 1
local angleScale = 90 / player:GetFov()
return math.sin(-player.freeAimYawOffset*angleScale) * Client.GetScreenWidth() / 2
end
end
return 0
end
// Get crosshair Y position
function PlayerUI_GetCrosshairOffsetY()
local player = Client.GetLocalPlayer()
if(player and not player:GetIsThirdPerson()) and kFreeAimOn == true then
local weapon = player:GetActiveWeapon()
if(weapon ~= nil and weapon.kUsesFreeAim) then
return math.sin(player.freeAimPitchOffset) * Client.GetScreenWidth() / 2
end
end
return 0
end<!--c2--></div><!--ec2-->
OffsetY is working OffsetX is not. There are no code errors. The effect is the same if OffsetX is:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function PlayerUI_GetCrosshairOffsetX()
local player = Client.GetLocalPlayer()
if(player and not player:GetIsThirdPerson()) and KFreeAimOn == true then
local weapon = player:GetActiveWeapon()
if(weapon ~= nil and weapon.kUsesFreeAim) then
// Don't ask me why this works. afaik sin(45) isn't 1
return math.sin(-player.freeAimYawOffset) * Client.GetScreenWidth() / 2
end
end
return 0
end<!--c2--></div><!--ec2-->
I was looking for spelling errors but just didn't catch it ::)
Working free aim with default crosshair for spikes
Working free aim without crosshair for spores (doesn't need a cross hair it's not ranged)
Play away to your hearts content. Values can be adjusted but the box size works for me on 16:9.
As an FYI Agiel, I left your code:
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->local angleScale = 90 / player:GetFov()
return math.sin(-player.freeAimYawOffset*angleScale) * Client.GetScreenWidth() / 2<!--c2--></div><!--ec2-->
in the release code, but I just tested with the original code and that works too on my 16:9 setup.
I believe Gimbal lock only affects marines as they are stuck on a plane. With the lerk I look straight up, go straight up, and a simple left or right rolls me to then I turn and swoop down.
The lerk flight is completely free and natural, just takes a little bit of play time to get used to the bounding box, then lerk flight is easy as normal, but with a better aiming ability.
This is really brilliant, and I'd like to thank you Agiel for the original code and I'd like to thank Mushokees for the original idea of adapting it to the lerk. I am really enjoying this. It is in my TDM mod, but I'm not going to update the release file just yet. Want to look a bit more at the gorge powerslide, and see if I can knock together a quick map for the mod :)
...
in the release code, but I just tested with the original code and that works too on my 16:9 setup.
I believe Gimbal lock only affects marines as they are stuck on a plane. With the lerk I look straight up, go straight up, and a simple left or right rolls me to then I turn and swoop down.<!--QuoteEnd--></div><!--QuoteEEnd-->
I guess the lerk does use 90 degrees fov then. The crosshair wont be aligned in 5:4 though since the fov there would be 70 degrees due to a bug in the current build as I mentioned earlier.
The problem with gimbal lock is with the aim vector. Try looking straight up and then a bit to the side. The view model and crosshair will look right but the aim vector will still be pointing straight up since the yaw component adds roll instead of yaw. What we need to do is somehow apply the pitch and yaw offsets while treating the view vector as the z axis. I'll look into it when I get the time (which I don't have atm since I'm going to Japan on Monday and it'll be a while until I get all set up over there ;).
Abandon ship.
Ok I understand this is a potential problem, however, I'd like to make a comparison to another flying object, a plane.
Now I know the difference, but when flying a plane, you roll to bank and yaw to turn slightly. When flying straight upwards, or downwards, if you roll to turn you just spin in one spot always facing straight up.
I know the actual ingame set up is mouse does Yaw and Pitch, but because we use 'Mouse Yaw' to turn (bank) right in flight, turning right when facing straight up should make the Lerk roll, just like a an aeroplane.
All we need to do is clamp free aim at 0 and 180 degrees, and this should be fine.
I know technically it's not correct, but because of the way the Lerk flight is controlled, spinning when aiming left or right while straight up or down is the correct flight simulated response.
<!--quoteo(post=1904039:date=Feb 17 2012, 04:03 AM:name=Harimau)--><div class='quotetop'>QUOTE (Harimau @ Feb 17 2012, 04:03 AM) <a href="index.php?act=findpost&pid=1904039"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Abandon ship.<!--QuoteEnd--></div><!--QuoteEEnd-->
I'm trying to save Agiel a lot of heartbreak. He doesn't want to try that, unless he can solve it, in which case we will be able to get the skulk view rotation working with the same code :)